Displaying the last updated date instead of the submitted date
In this recipe, we will be changing the contents of the $date
template variable which, by default, displays the creation date of the node, with the node's last updated date instead. This is useful in situations where the freshness of content depends on when it was last updated rather than its overall age.
Getting ready
We will be using the myzen theme created earlier in this book as the example theme in this recipe. It is also assumed that the node.tpl.php
file is available in its templates
folder.
How to do it...
Manipulating the $date
variable can be performed using the following steps:
Navigate to the myzen theme folder at
sites/all/themes/myzen
.Open the
template.php
file in an editor.Look for the
myzen_preprocess_node()
function; if unavailable, create askeleton()
function of the same name.Edit it so that it effectively functions as outlined in the following. Any pre-existing changes will need to be merged appropriately.
function...