Where the menu items “animated gifs” and “background midi music” are sub menus, or children, of the menu item services. Say you want to have a menu structure like this: about us It was not automatically expanded on the page I clicked. This was all good, until I discovered that the child of each menu link was not displayed if I clicked the parent. In one of my sites I chose to use the menu "main menu", and use it in the region "navigation". Here is the decorative output of the code above: This is the function from : menu_get_object($type = 'node', $position = 1, $path = NULL) The function itself takes arguments for other modules, if they provide a load object. Note that $node will be NULL if you are not on a node page, i.e a page created by some module. Use node title as alt text and title text on a fancy gif animation. The answer is extremely simple: The function menu_get_object() $node = menu_get_object() I googled “how to access the node object”, “how to load the node object”, "load node object in custom module" and so on. I decided I should start sharing my answers to problems I have googled for, to save others the trouble of going through the long process of figuring things out for themselves.įirst problem: I am writing a module that displays blocks, and I want to access the node object to use some variables from the page being viewed in order to use these variables to construct some of the contents of the block.
0 Comments
Leave a Reply. |