Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By bjste on
Hi there...
I'm new with php... and I'm trying to figure out where to edit to get a span arround the primary links.
I tryed looking at the page.tpl.php file, but that's not the place I guess...
Could anyone give me a hint??
Comments
Page.tpl is the right place
Page.tpl is the right place to do it!
Could you explain how? Caus
Could you explain how?
Caus the things I've tryed just results in errors...
I assume it's this section that schould be edited:
if (isset($primary_links)) :
print theme('links', $primary_links, array('class' => 'links primary-links'))
endif;
It is clear that it's a Menuitem I need.. and not a span arround the whole menu, right?
I need to use the span to place a piece of bagground-image.
template.php is what you
template.php is what you want.
put this in there:
What that does is override theme_links(), simply by wrapping the link title with a span on these lines:
So that should do it, granted I didn't test that exact snippet... You'll need to clear the theme registry at /admin/settings/performance.
:-)
I can't get this to work... I
I can't get this to work... I think I need a little more instruction on how to do this...
It seems like a lot of code to need to get a little span tag?
Do I have to remove the excisting 3 lines of code in page.tpl.php?
Should I edit anything in this code or should it just work?
Here's a quick rundown... The
Here's a quick rundown...
The theme_links() function is part of Drupal core and it determines what is outputted when you use
theme('links', $primary_links, array('class' => 'links primary-links'));
in your page.tpl.php file (or wherever).Now, any function that starts with theme_whatever() can be overridden by your site's theme in template.php. In order to do that, you need to copy the entire original function, make your changes, and put that in template.php. You MUST rename the function from "theme_whatever()" to "yourthemename_whatever()" in template.php though.
After that, go to http://example.com/admin/settings/performance and click "Clear cached data" so the override will be found.
The stuff you have in page.tpl.php in your previous post should stay there. And the snippet I posted in my last post you can copy/past (it already has the change in it), but you need to just rename the function to yourthemename_links
Thank you so much for your
Thank you so much for your help! I really appreciate it! It works perfect now :D
You're welcome, glad you got
You're welcome, glad you got it working. :-)
Thanks roper
I was converting theme from html template to Drupal theme from last 3 dayes i was searching same thing now i got. thanks again you Rock man.
zakir.gori