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?

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

  • 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 Jul 27 '11 at 14:00
  • Wrap your code in a function, I'm pretty sure that's the only way to go. – Eelke Jul 27 '11 at 14:04
  • @Eelke: In template_preprocess_page can you access fields of the node? – User Jan 8 '12 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 Jan 8 '12 at 10:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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