By smithaa02 on
In 4.x, it was really easy...
print theme('links', $primary_links, "
"); ...or say... print theme('links', $primary_links, " ** ");
But with 5.x, the primary link code for the theme looks something like this:
print theme('links', $primary_links, array('class' =>'links', 'id' => 'navlist'))
And this doesn't print any separator at all. I need the double pipes (||) to appear for my look, but don't know how to do this with 5.x.
Ideas?
Comments
It's not easy
Drupal 5 assumes you want your links in an unordered list. If you don't want that, you need to override theme_links by creating a function mytheme_links in template.php in your theme directory (should be sites/all/themes/mytheme/template.php).
The separator is in the line $output .= ' || '; in the code below:
reply
This actually won't work in my case because I have separate instances of my primary menu being displayed but in dramatically different formats.
For anybody that is curious, my final solutions was to code into my template the following:
$firstpass = 1;
foreach ($primary_links as $p) {
if (!$firstpass) {echo " || ";}
$firstpass = 0;
echo "".$p['title']."";
}
Is there any shorter code,
Is there any shorter code, seems like a lot just to add a | separator | I only want to add it to the primary links
This did not work in zen theme...
Hi, I have tried your solution but unfortunately its not working in my zen theme. I mean nothing happened. Is there any other solution? Thanks :)
There may be an easier way though...
I have this set up for a site. Instead of having drupal stick in separation characters you do it using the style definitions.
My site uses a theme based on foliage (which in turn was based on bluemarine). I achieve the desired look with the following line in style.css
It's not exactly the double pipe characters you had previously. But it's a border-style which appears visually similar. You can see the various options you have for styling this "border" at: http://www.w3schools.com/css/tryit.asp?filename=trycss_border-style
You may also have to adjust the border settings for ul.links li.first and ul.links li.last to get this to work properly in your theme.
Thank you for posting this...
after a little bit of digging, this is my favorite approach. I ended up using
for a Zen based theme for displaying it as "| Menu 1 | Menu 2 | Menu 3 |"
Did not work in zen theme
Hi gerald, i tried your solution but it did not work in the zen theme. Hhmmm, any ideas? Thanks :)
A few ideas
The CSS code above was used in Drupal 5; not sure if this still works in 6. In my case, I created a Zen subtheme and added the CSS code to the zen/[mysubtheme_name]/[mysubtheme_name].css file after where it says
#primary /* Primary links */
{
}
Hope this helps,
Gerald
Does anyone know of a better
Does anyone know of a better way to get a pipe only in a footer menu and not anywhere else?
Thanks.
Try with CSS
See the comment just above: http://drupal.org/node/113890#comment-913761
and use #footer instead of #primary.
Hope this helps,
Gerald
Solution for Drupal6
Well, it's not an easy solution and there might be another way around, but this is how I got it working for Drupal6 (menu secondary-links):
I'm quite new to Drupal, so if anyone has improvements to this code, just let me know