Alright, this one is a bit tricky. I'm using the theme() function and theme_links__system_main_menu to render the main menu in a specific way on the front page. All the menu items link too basic pages.

The idea is that when hovering over a menu item, a pop-up appears with the content of a field called 'Preview' that's on the basic page of which the menu item is linked to. The pop-up itself is a simple CSS thing, so what I'm looking for is a way to access the information of the node in question.

I know $variables contains the link to the node, is there perhaps a function that gives you node information by link?


Assuming that you need to access to $node to populate the preview:

You will need to load the node object for access to $node. So lets say you extract the href from $variables, you wont be able to load node based on the url, atleast I dont know any function that does it. You will need to extract (php explode etc) node nid and then use node_load($nid) to load the $node object and then you can populate the preview based on a field of $node.

Where to write the code?

You can either override the theme function or use the preprocess, the preprocess for this should be (though not sure) yourtheme_preprocess_links__system_main_menu(&$vars) and theme override will be yourtheme_links__system_main_menu. I hope you understand the difference between theme function override and preprocess. I'd suggest preprocess to add preview in $variables and then overriding theme function to use that value. OR, you can build the preview and add it as an attribute to the link.

Hope that helps.

|improve this answer|||||
  • I managed to get the node using the href with menu_get_item(). It returns a rather massive array, though it lists the field content as well. – Zedicius Jun 8 '12 at 7:29

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.