By depe86 on
Hi!
How can I add a simple 'span'-tag to all my menu items in the main_menu in my theme?
I would like this layou:
ul
li a span Länk /span /a /li
/ul
Thanks!
Hi!
How can I add a simple 'span'-tag to all my menu items in the main_menu in my theme?
I would like this layou:
ul
li a span Länk /span /a /li
/ul
Thanks!
Comments
_
You could add the following code to your theme's template.php (if the function doesn't already exist) -
This is a slight modification of the code that's supplied with the Zen theme - remember to replace yourthemename with the name of your theme!
Thank you for your reply
Thank you for your reply pbarnett!
But that didn´t result in a span-tag. Wrote the code in my theme-template, changed the function name my theme name.
I cleared my cache in site 'Configuration'.
Anything more to do before if works?
Thanks again!
_
Did you clear the menu cache? I always install the Administration menu module as it makes clearing specific caches much simpler...
I cleared the cache under
I cleared the cache under Configuration -> Performance -> Clear all cache
So the menu cache should been cleared to, right?
I´ve installed the administration menu just so I could clear the menu cache, but couldnt find that operation anywhere...
Your the best Pete thats trying to help me!
Thanks!!!
_
It's at the top left, under 'Home'.
I checked the code on a test installation, and it's definitely adding a span :-
Hi again! I cleared all cache
Hi again!
I cleared all cache in the administration menu, but still no luck.
Run cron, update.php, change theme and then back again.
I´m using the regular main_menu (primary_menu in Drupal 6).
Im not a Drupal 7 fan :(
Should the theme-settings.php be empty?
My theme automaticly 'read in' the template.php?
Thanks again, your so helpful Pete!
_
Oh dear!
I hadn't noticed the D7 tag - theme_menu_item_link doesn't exist in D6 :-(
The corresponding function in D7 is
so you could try
see also the l() function.
Now it finally worked. The
Now it finally worked.
The code in my template.php, refreshed the cashe under "Performance".
Thank you Pete for all your help!
Saved me a lots of time!!
/Daniel
_
Excellent! I hadn't actually tested the code, so I'm pleased that it worked...
It doesn't work for the main menu....
Confirmed. It doesn't seem to work for the main menu. (primary and secondary links). How do you modify this to do so?
Primary menu
Why does it work with some of block menus only, but not with my primary menu?
This doesn't work with the Primary Menu
I'm having some trouble with this as well when trying to format my main menu.
This is what I ended up
This is what I ended up doing.
template.php:
And in page.tpl.php:
My custom menus were actually replacing my menu main depending on url.
Class that corresponds to individual links
Hi.
I adapted what you did above to suit my design, and it worked perfectly.
I'm wondering though if it's possible to assign a class to, in this case, the span, that varies depending on the link.
In the template.php file I have this:
I altered the above solution to include a small div just before and just after each link - and I have no problem with this, it's all coming out just fine.
The point of the divs is that when the link is hovered over, it changes colour. However, I want each link to change to a different colour; e.g. Link A when hovered the div's background changes to red ... Link B when hovered the div's background changes to yellow.
I know all the CSS to do that, but what I don't know how to do is to assign a class to div id="topnavblip" that will correspond with each link. I know that drupal assigns each link a class, such as "menu-218" and "menu-219". I figured I could put a class in my CSS called menu-218 and menu-219 and assign the relevant properties to get the div changing colour (for instance menu-218 to red and menu-219 to yellow), but I don't know how to coordinate this with the div in the template.php file.
Hope this makes some sense to somebody! Would appreciate any help.
Thanks.