3

My intentions is to take a panelized page and use fields provided in that page to create class names on the body element.

When I preprocess the page, I don't get the original node information and can't pull the information I need.

My panelized page has 1 pane that has the node-> content pane in there.

If I could just get the NID of the current page, then it would be okay. But that doesn't even show up in the variables in the theme_preprocess_html() when a page has been panelized.

3
  • Nevermind, The solution that I needed was just to use arg() to get my node id and then I was able to use node_load() to get/check values I wanted to use for the classes_array to add to the body.
    – Zeropx
    Jan 6 '14 at 12:29
  • You could also use $node = menu_get_object('node'); to retrieve the loaded node from the menu router cache. Jan 6 '14 at 21:21
  • David, menu_get_object() was exactly what I needed. Thanks!
    – Zeropx
    Jan 8 '14 at 4:47
4

Solution was to use menu_get_object(). Here is a nice article outline usages of it as well.

$node = menu_get_object('node');

Thanks you David for the answer.

0

If the nid is in the URL, you can use the arg function to get it.

2
  • That's what I ended up doing. Works good enough for now, i'd still like to find a way to make it happen within the preprocess system either with a custom module or in template.php somehow. Just a common technique I find my self doing.
    – Zeropx
    Jan 6 '14 at 20:20
  • Well, you can call arg() from within YOURTHEME_preprocess_html. Also, the HTML template is really clueless about its contents, as the pieces are rendered before its containers. Maybe you should take a look at hook_page_alter. Jan 7 '14 at 4:22

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.