Closed (fixed)
Project:
Elements Theme
Version:
6.x-1.x-dev
Component:
Code
Priority:
Critical
Category:
Bug report
Assigned:
Reporter:
Created:
9 Apr 2009 at 13:35 UTC
Updated:
27 Jun 2009 at 16:00 UTC
Primary links are not working because of the function I used to print the link titles. I don't have time to review it right now but this will get solved very soon. If anyone has time to work on this, here is the function:
/**
* Return a themed set of links.
* An override of theme_links()
* Modified to use simple text styling instead of HTML & CSS
*
* @see theme_links
*/
function phptemplate_links($links, $attributes = array('class' => 'links')) {
$output = '';
// Change the way primary links are rendered
if($attributes['class'] == 'links primary-links') {
$linklist = array();
$href = $link['href'] == "<front>" ? base_path() : base_path() . $link['href'];
foreach ((array)$links as $key => $link) {
$linklist[] = '<a href="'. $href .'"><span class="menu-items"><h3>'. $link['title'].'</h3>'.$link['attributes']['title'].'</span></a>';
}
// Return the links joined by a '|' character
return join($linklist);
}
if (count($links) > 0) {
$output = '<ol'. drupal_attributes($attributes) .'>';
$num_links = count($links);
$i = 1;
foreach ($links as $key => $link) {
$class = $key;
// Add first, last and active classes to the list of links to help out themers.
if ($i == 1) {
$class .= ' first';
}
if ($i == $num_links) {
$class .= ' last';
}
if (isset($link['href']) && ($link['href'] == $_GET['q'] || ($link['href'] == '<front>' && drupal_is_front_page()))) {
$class .= ' active';
}
$output .= '<li'. drupal_attributes(array('class' => $class)) .'>';
if (isset($link['href'])) {
// Pass in $link as $options, they share the same keys.
$output .= l($link['title'], $link['href'], $link);
}
else if (!empty($link['title'])) {
// Some links are actually not links, but we wrap these in <span> for adding title and class attributes
if (empty($link['html'])) {
$link['title'] = check_plain($link['title']);
}
$span_attributes = '';
if (isset($link['attributes'])) {
$span_attributes = drupal_attributes($link['attributes']);
}
$output .= '<span'. $span_attributes .'>'. $link['title'] .'</span>';
}
$i++;
$output .= "</li>\n";
}
$output .= '</ol>';
}
return $output;
}
Comments
Comment #1
summit commentedHi, just a suggestion.
Can't you copy primary links function from another theme?
Does anybody know a primary links functions which could be used for this theme.
Theme is looking great!
greetings, Martijn
Comment #2
ipwa commentedI haven't seen a theme that prints out menu descriptions and menu titles the way this theme does. You don't need a function to print primary links because its part of Drupal core, you can just
print $primary_links;. I will try to fix this major bug asap.Comment #3
ShaunPatrick commentedTryed to figure it out but to no avail
Comment #4
falcor commentedAny update? Just bumping this with my question. Thanks!
Comment #5
pipicom commentedChanged the upper part of your template.php code to this:
and it works!
Comment #6
gjones commentedYou sir, are an internet hero!
Comment #7
ipwa commentedThis has been committed to dev right now, so in up to 12 hours you can download the theme with primary links working. Thanks very much pipicom, I really didn't have much time last month to look into my contrib themes, I'm really glad you sorted it out. You'll get proper credit in the first beta release note ;)
Comment #8
pipicom commentedCool! Thanks. I have already used your theme here: http://tsakirismarine.gr/ though I changed some things
Comment #9
summit commentedWould nice to know what you changed..
thanks for considering telling us.
greetings, Martijn
Comment #11
apoc1 commentedPrimary links are still not working for the people who can't enabel clean url's. The secondary links do work, primary's not. It links to .../node/1 when it should be .../?q=node/1
Any idea how to fix this? I'm into it now for a while but can't find any solution (don't have a great php knowledge...)
Comment #12
apoc1 commentedI got it working now by changing the same line in template.php that pipicom changed with the following:
The only thing I noticed is that via this way, you can't link the front in your primary links...
Comment #13
ipwa commentedI can confirm primary links don't work with clean urls disabled and when you link to front page, so opening up this issue again.
Comment #14
ipwa commentedThis is not the same issue as the initial one, so opening a new one: http://drupal.org/node/490758