Tested on: Zen theme, Drupal 5.7
- Copy function theme_links from includes/themes.inc
- Paste it into your template.php
- Rename it in theme_primarylinks (or anything you want)
- In your page.tpl.php, change
- print theme(‘links’, $primary_links);
- to print theme(‘primarylinks’, $primary_links);
- Apply some changes to theme_primarylinks to customize your primary links.
According to theme manual, for any first argument passed to theme function a theme_functionname function is called.
thanks lot for providing help to customize drupal primary links
Thanks, mate!
That really helped me out! =)
Thanks, Great tip!
I’m using this technique in a site I’m developing on Drupal5.
I found a simple way to change image depending on the active link too, here is a piece of my code form “theme_primarylinks” function (I ave a PrimaryLink folder in my images in there I have a menuname.png image and a menunameActive.png image):
———————————————
// Initialize fragment and query variables.
$link[‘query’] = isset($link[‘query’]) ? $link[‘query’] : NULL;
$link[‘fragment’] = isset($link[‘fragment’]) ? $link[‘fragment’] : NULL;
if (isset($link[‘href’])) {
$linkactive = “”;
// should this button be active?
if(substr($link[‘attributes’][‘class’], -6) == “active” ) { $linkactive = “Active”;}
// if an active image exixts use it!
if(file_exists(“/opt/lampp/htdocs/” . path_to_subtheme() . “/images/PrimaryLinks/” . $link[‘title’] . $linkactive . “.png”)) {
$output .= l(“”,
$link[‘href’], $link[‘attributes’], $link[‘query’], $link[‘fragment’], FALSE, $html = TRUE);
}
else {
$output .= l($link[‘title’], $link[‘href’], $link[‘attributes’], $link[‘query’], $link[‘fragment’], FALSE, $html);
}
}
…
————————————————————-
http://drupal.org/node/248522
Use a custom function in your template.php to get to the Links and the active item, should be much more easy.
How about a video on how to turn the primary links to an image. Gosh, I’ve been hours looking for a step by step tutorial. I feel so frustrated =( I’m not that versed in PHP, whew.. help? anyone.. at least just reference. =)
That should help me get started in the right direction. Thanks!