Fix for Code to print "top parent" node of the site section

  1. <?php
  2. $m_items = _menu_get_active_trail();     // get active menu trail into an array
  3. $m_item = $m_items[1];                           // the second entry is the top parent (assumes we have one main menu container, e.g. primary links)
  4. print menu_item_link($m_item);               // this function takes the menu id (mid, which is $m_item) and creates a link to the page
  5.  
  6. $link_array = menu_item_link($m_item, FALSE); // this gets the menu item into an array
  7. print 'Title:' . $link_array['title'];
  8.  
  9. // you can therefore add the section to the css by doing this:
  10. // $body_classes[] = $link_array['title'];
  11. ?>