By KNerd Terry on
I'm trying to make a menu that has the parent items using images and child items as text... The way I'd like to see this output is
<ul class="menu">
<li id="home" class="leaf"><a href="" title="Home"><span class="hidden">Home</span></a></li>
<li id="about" class="expanded"><a href=" title="About" class="active"><span class="hidden">About</span></a>
<ul class="menu">
<li>.....etc....</li>
</ul>
</li>
<li id="contact" class="leaf"><a href="" title="Contact"><span class="hidden">Coffee</span></a></li>
</ul>
I've found a php template to add to my template.php file that will add the id to the list-item for the background, this is
<?php
function phptemplate_menu_item($mid, $children = '', $leaf = TRUE) {
$link = menu_item_link($mid);
$css_id = strtolower(str_replace(' ', '_', strip_tags($link)));
return '<li id="' . $css_id . '" class="' . ($leaf ? 'leaf' : ($children ? 'expanded' : 'collapsed')) .'">'. $link . $children ."</li>\n";
}
?>
I just need to figure out how to add the around the item title, everything else I can do with the css.
I have a (less than) basic understanding of php and how drupal works, but I know my way around CSS and have made a few custom themes so can figure that part out.
Any help is appreciated!
Thanks, KNerd Terry
Comments
background-image
Define a
background-imagefor each root list item id in your CSS?That might do the trick.
thanks uotony
But I'm doing that already. I need to add the span around the item title, thats where I'm stuck... any ideas?
left out of initial post
I just realized a bit of code was left out of this sentence:
"I just need to figure out how to add the *span with class=hidden* around the item title, everything else I can do with the css."
added a phptemplate_menu_item_link but no go
I found a function to change the menu_item_link but I'm getting an error!
warning: Missing argument 2 for phptemplate_menu_item_link()
Here are my two templates
its working...
but I'm not sure why. All I did was change the second function to this:
So I just removed phptemplate_menu_item_link with menu_item_link and now it writes the span around the item title.
and in 6.x?
I'm trying to do the same thing in 6.x.
I found this, http://drupal.org/node/143322 , I thought to add a child menu item to use it as description of the parent and linking it to , but I always get warning: Missing argument 2 for phptemplate_menu_item_link().
Any suggestion?