DrupalBin
Submit Code
About
Recent Posts
Fix for Code
3 hours 53 min
ago
Fix for Code
3 hours 59 min
ago
Fix for Code
4 hours 7 min
ago
Fix for Code
4 hours 32 min
ago
more
Tags
CCK
drupal
fapi
jquery
menu
module
Panels
php
simpletest
test
theme
views
more tags
User login
Log in using OpenID:
What is OpenID?
Username:
*
Password:
*
Create new account
Request new password
Log in using OpenID
Cancel OpenID login
Home
Fix for Code to print "top parent" node of the site section
View
Download
Fix
This fix will not be saved to the database until you submit.
Summary:
Tags:
Any tags you'd like to associate with your code, delimitered by commas (example: Views, CCK, Module, etc).
Source code:
*
<?php $m_items = _menu_get_active_trail(); // get active menu trail into an array $m_item = $m_items[1]; // the second entry is the top parent (assumes we have one main menu container, e.g. primary links) print menu_item_link($m_item); // this function takes the menu id (mid, which is $m_item) and creates a link to the page $link_array = menu_item_link($m_item, FALSE); // this gets the menu item into an array print 'Title:' . $link_array['title']; // you can therefore add the section to the css by doing this: // $body_classes[] = $link_array['title']; ?>
Syntax highlighting mode:
ActionScript
ColdFusion
Diff
Drupal
Drupal 5
Drupal 6
HTML
Javascript
MySQL
PHP
Python
robots.txt
SQL
Text
Select the syntax highlighting mode to use.