How to add .first and .last class to this code (code inside)
sakib000 - September 23, 2008 - 03:28
Hello,
I am printing my primary links with this code to help make dropdown menu
<?php
if (isset($secondary_links)) {
//Code credit Wolfgang <a href="http://drupal.org/project/multiflex37
" title="http://drupal.org/project/multiflex37
" rel="nofollow">http://drupal.org/project/multiflex37
</a> $msm = variable_get('menu_secondary_menu', 0);
print theme('menu_tree', $msm);
}
?>And this in template.php
<?php
function phptemplate_menu_tree($pid = 1) {
$msm = variable_get('menu_secondary_menu', 0);
if ($tree = menu_tree($pid)) {
$ul = $msm == $pid ? '<ul>' : '<ul class="menu">';
return "\n$ul\n$tree\n</ul>\n";
}
}
function phptemplate_menu_item($mid, $children = '', $leaf = TRUE) {
$msm = variable_get('menu_secondary_menu', 0);
$menu = menu_get_menu();
if (in_array($mid, $menu['visible'][$msm]['children'])) {
return '<li>'. menu_item_link($mid) . $children ."</li>";
} else {
return '<li class="'. ($leaf ? 'leaf' : ($children ? 'expanded' : 'collapsed')) .'">'. menu_item_link($mid) . $children ."</li>\n";
}
}
?>But it is printing simple menu code like
<ul>
<li class="active">Home</li>
<li>About</li>
<li>About you</li>
</ul>Can anyone edit this code to make it print menu with first and last class (or only first) like this
<ul>
<li class="active first">Home</li>
<li>About</li>
<li class="active last">About you</li>
</ul>Thanks
