By eldesigner on
Devel themer showed that the function to override for primary links is theme_link(), but when I overrode that, Drupal also changed other types of links like "Comment", etc.
My override is:
<?php
function MYTHEME_links($links, $attributes = array('class' => 'links')) {
global $language;
$output = '';
foreach ($links as $key => $link) {
if ($link['href'] == '<front>') {
$link['href'] = '';
}
if (stristr($link['href'], 'http://') == TRUE){
$output .= '<div class="menuitem"><div class="menubgleft"</div><p><a href="' . $link['href'] . '">' . $link['title'] . '</a></p><div class="menubgright"></div><a href="' . $link['href'] . '"><div class="diamond"></div></a></div>';
}
else {
$output .= '<div class="menuitem"><div class="menubgleft"</div><p><a href="/' . $link['href'] . '">' . $link['title'] . '</a></p><div class="menubgright"></div><a href="/' . $link['href'] . '"><div class="diamond"></div></a></div>';
}
}
return $output;
}
?>
Is there a more appropriate function to override to just change the primary links? Or do I need to write a conditional statement to do this only if the link is a primary link?
Thanks in advance,
Evan.
Comments
theme_links() as you
theme_links() as you discovered themes more than just the primary links. Some themes implement a different theme function just for the primary links.
Theme_links specific block
I'm stuck in a similar situation. I would like to make a change only to a specific set of links.
In my case it's the core language switcher, to change the text string to a two character string: for example English into En, Deutsch into De, etc....
Thanks
Alan
Use if condition
Use if condition mention below to do changes for only particular type of links in hook _links
For example if i want to change only primary links i use this
Cheers,
Anil Sagar,
Lead Drupal Developer,
Azri Soulutions,
http://azrisolutions.com/
Hi Anil, I run into the same
Hi Anil,
I run into the same problem.
In my case the links does not have any class. I want to use separate theme_link function for a set of links that are generated in a block.
any more ideas?