Mark up lastupdate with time element

Discussions and requests related to new CMSimple features, plugins, templates etc. and how to develop.
Please don't ask for support at this forums!
Post Reply
cmb
Posts: 14225
Joined: Tue Jun 21, 2011 11:04 am
Location: Bingen, RLP, DE
Contact:

Mark up lastupdate with time element

Post by cmb » Sun Feb 08, 2015 4:19 pm

Hello Community,

quite a while ago Termin has suggested to markup the last update of page_params as time element. IMO that makes sense, so I suggest to do it for lastupdate() of the core also (XH 1.7). A minimal patch:

Code: Select all

Index: cmsimple/tplfuncs.php
===================================================================
--- cmsimple/tplfuncs.php	(revision 1480)
+++ cmsimple/tplfuncs.php	(working copy)
@@ -423,10 +423,10 @@
     } else {
         $t .= ' ';
     }
-    return $t
-        . XH_formatDate(
-            filemtime($pth['file']['content']) + (isset($hour) ? $hour * 3600 : 0)
-        );
+    $time = filemtime($pth['file']['content']) + (isset($hour) ? $hour * 3600 : 0);
+    return $t . '<time datetime="' . date('c', $time) . '">'
+        . XH_formatDate($time)
+        . '</time>';
 }
 
 
Index: plugins/page_params/index.php
===================================================================
--- plugins/page_params/index.php	(revision 1480)
+++ plugins/page_params/index.php	(working copy)
@@ -191,8 +191,9 @@
     ) {
         $temp = '<div id = "pp_last_update">'
             . $plugin_tx['page_params']['last_edit'] .  ' '
+            . '<time datetime="' . date('c', $pd_current['last_edit']) . '">'
             . XH_formatDate($pd_current['last_edit'])
-            . '</div>';
+            . '</time></div>';
         if ($pd_current['show_last_edit'] == 1) {
             $c[$pd_s] .= $temp;
         } else {
Termin had also suggested to add an appropriate class attribute to the time element, but that might not be necessary[1], as there's already div#pp_last_update around it for page_params, and for the core lastupdate() that can be done in the template, if not already happened.

Termin further suggested to add an appropriate itemprop attribute to the time element, but I'm not sure whether we should do that.

[1] It might be necessary for older browsers, though.
Christoph M. Becker – Plugins for CMSimple_XH

cmb
Posts: 14225
Joined: Tue Jun 21, 2011 11:04 am
Location: Bingen, RLP, DE
Contact:

Re: Mark up lastupdate with time element

Post by cmb » Tue Apr 21, 2015 8:37 pm

Done (r1556).
Christoph M. Becker – Plugins for CMSimple_XH

Post Reply