This problem is driving me crazy! On my website, in node.tpl.php, print render($content['links']) prints out all the links in the system. These include the "Read More" link, the comment count, add more content, and blog links if the content type is "blog."
Here's my problem: "Read More" is the first link. I need it to be the last link. And in fact, on many theme demo sites, this is exactly the case. But how does one alter the order in which links are rendered???
I know there are a couple of solutions using a preprocess function, or adding logic to the node.tpl.php file, but when I check these other demo sites with Firebug, it's clear that the links are coming straight out of the render array. So how is this being done? I'm clueless.
For instance, here's the link html from my site, using Bartik:
<div class="link-wrapper">
<ul class="links inline">
<li class="node-readmore first">
<li class="blog_usernames_blog">
<li class="comment-comments last">
</ul>
</div>
Here's the same link code from Danland's demo site:
<div class="links">
<ul class="links inline">
<li class="blog_usernames_blog first">
<li class="comment_comments">
<li class="node_read_more last">
</ul>
</div>
It's clear that the Read More link order is different, but how? I've gone through all of the Danland theme code, and I don't see any preprocess function or alterations to the node template that would explain this.
Can anyone solve this mystery for me??
Comments
I did not test this, but you
I did not test this, but you can try to get the read more link from $content['links'], unset it from $content['links'], and then add it again as last element on $content['links'].
Fernando Correa da Conceição
http://jaguaribe.net.br
$content['links'] automatically unset
AFAIK $content[] fields are automatically unset if you render them separately anywhere else.
Here is how I did something
Here is how I did something similar:
http://api.drupal.org/api/drupal/includes--theme.inc/function/theme_links/7
Goto /includes/theme.inc and copy this function to your template.php file:
function theme_links($variables)
In your template.php file rename it to
YOURTHEME_links($variables)
I added an image to my read more links like so by adding this code just above the $i++
if(@$variables['links']['node-readmore'] && isset($link['href']) ) {
$output .= l('SOME IMG TAG', $link['href'], $link);
}
You can now hack your custom function as much as you like.