2

I've set up a couple of variables in my template_preprocess_node(). How can I access them within a page template? I can access the $node variable, but it doesn't seem to have been preprocessed.

How can I force preprocessing?

1 Answer 1

2

The node variable for page templates is set in template_preprocess_page http://api.drupal.org/api/drupal/includes--theme.inc/function/template_preprocess_page/6 You should override that function in your theme

4
  • 1
    I know, but since I've already overridden preprocess_node, I'd rather prefer not to duplicate the code, and use the preprocessed node within the page.
    – pasine
    Commented Jul 27, 2011 at 14:00
  • Wrap your code in a function, I'm pretty sure that's the only way to go.
    – Eelke
    Commented Jul 27, 2011 at 14:04
  • @Eelke: In template_preprocess_page can you access fields of the node?
    – User
    Commented Jan 8, 2012 at 10:02
  • 1
    Actually I can answer that myself. Yes you can. In Drupal 7 they seem to be available as $variables['node']->field_example.
    – User
    Commented Jan 8, 2012 at 10:19

Your Answer

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

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