0

I found a code in drupal page in this url http://api.drupal.org/api/drupal/includes%21menu.inc/function/theme_menu_tree/6#comment-1073

code is

<?php
function phptemplate_menu_tree($tree,$menu_name="") {
     return '<ul class="menu menu-$menu_name ">'. $tree .'</ul>';
}
?>

it is written that we can customize every menu by css and also adding $menu_name.

but even though that I have added this function into my template.php and it is working , $menu_name variable is always empty

really the target that I am following is : I want to modify the css class of the ROOT us base on menu name.

for example for primary links , i want to have this return out put

'<ul class="menu menu-primary-links ">'. $tree .'</ul>'

or for secondary links i want to have this return output

'<ul class="menu menu-secondary-links ">'. $tree .'</ul>'

$tree includes all nested li items from the selected menu.

please help me

2 Answers 2

1

page.tpl.php

for admin menu

    <?php print '<ul id="nav-admin" class="menu   clearfix">'.menu_tree($menu_name = 'navigation').'</ul>';?>

//for primary menu
 <?php print  '<ul id="nav-primary" class="menu clearfix">'.menu_tree($menu_name = 'primary-links').'</ul>'; ?>
//for secondary menu
 <?php print  '<ul id="nav-secondary" class="menu clearfix">'.menu_tree($menu_name = 'secondry-links').'</ul>'; ?>

template.php

function menu_tree($tree}{return $tree;}

1
  • page.tpl.php for admin menu <?php print '<ul id="nav-admin" class="menu clearfix">'.menu_tree($menu_name = 'navigation').'</ul>';?> //for primary menu <?php print '<ul id="nav-primary" class="menu clearfix">'.menu_tree($menu_name = 'primary-links').'</ul>'; ?> //for secondary menu <?php print '<ul id="nav-secondary" class="menu clearfix">'.menu_tree($menu_name = 'secondry-links').'</ul>'; ?> template.php function menu_tree($tree}{return $tree;}
    – moideen
    Aug 13, 2013 at 11:43
0

Try out by calling

<?php print theme('links', $primary_links, array('class' =>'menu-primary-links')); ?>

to include primary links to the required template file. No need for phptemplate_menu_tree function in template.php

1
  • I know this function. but this function doesn't render the whole tree structure. I mean this function doesn't load nested ul that is located inside the LI tags - only the level 0 is appeared when we use theme function.
    – Mehrdad201
    Jun 26, 2012 at 7:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.