Monday, January 11, 2010

Code for primary and secondery links in Drupal

Chameleon combines the placement of the primary and secondary links, basically locking the secondary links into a subnavigation role. You don't have to group these two items together in this fashion, but it is one logical option. Note the snippet below. In both cases, the display of the links is conditional (depending on what is enabled by the administrator). If either one is enabled, then it will appear inside a div with the class navlinks. Additionally, to be able to style each set of links individually, both $primary_links and $secondary_links are provided with a unique class and id.


$primary_links = theme('links', menu_primary_links(), array('class' =>
'links', 'id' => 'navlist'));
$secondary_links = theme('links', menu_secondary_links(),
array('class' => 'links', 'id' => 'subnavlist'));
if (isset($primary_links) || isset($secondary_links)) {
$output .= ' <div>';
if (isset($primary_links)) {
$output .= $primary_links; }
if (isset($secondary_links)) {
$output .= $secondary_links; }
$output .= " </div>\n";
}

No comments: