In this recipe, we will be replacing 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 with content such as fora, news, and so on where recency is an important indicator of the freshness of a node.
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.
Manipulating the $date
variable can be performed using the following steps:
1. Navigate to the myzen theme folder at
sites/all/themes/myzen
.2. Open the
template.php
file in an editor.3. Look for the
myzen_preprocess_node()
function; if unavailable, create a skeleton function of the same name.4. Edit it so that it effectively functions as in the following snippet. Any pre-existing changes will need to be merged...