I'm using the adaptive theme with the pixture_reloaded subtheme, and I'm trying to place a preprocess to change the format of $date. This is what I thought should do the trick but haven't had any luck with getting the output I want.

In ./sites/all/themes/adaptivetheme/adaptivetheme_subtheme/template.php, I've entered the following:

function adaptivetheme_subtheme_preprocess_node (&$vars)
   $vars['date'] = format_date($node->changed);

In ./sites/all/themes/adaptivetheme/adaptivetheme/templates/page.tpl.php, I've added:

print $date;

under the location where the main content is rendered.

The date prints where I want it to, however, the date format is still showing up as the date which the content was created, and not the updated date. I've edited the content multiple times as well.

Is my preprocess hook supposed to be placed into a different area to make this work?

Any help is much appreciated.

1 Answer 1


Since you are using a node preprocess function, the variable you created will be available to the node.tpl.php file, not the page.tpl.php file. You need to either move your print statement to node.tpl.php or implement template_preprocess_page() in template.php.

  • does format_date(node->changed) look right to you? If I do the format date with formatting, it works, but when passing node->changed it breaks the operation and it returns a white screen. Jan 13, 2012 at 16:20
  • Assuming Drupal 7 - in a node preprocess, the variable you want is $vars['changed'] and in a page preprocess, the variable you would want is $vars['node']->changed. I suggest looking into the devel module, which offers some helper functions for printing out variables in a reader-friendly format.
    – sheena_d
    Jan 13, 2012 at 16:28
  • I found the two variables that I can use, changed and last_activity. However, both of them print the date "Wed 1969-12-31 17:00". I believe this is the date the system uses when a user creates an account and doesn't log in. Does this mean that the update times aren't being tracked? Jan 13, 2012 at 17:21
  • NVM! found it out. Turned on error reporting and noticed that $node wasn't being recognized. I had to call $node with $vars['node']. However, you get the answer because the big part of the problem was not placing this in node.tpl.php. Jan 13, 2012 at 17:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.