tags:

views:

93

answers:

3

In the comment.tpl, $links is printed to show the reply and edit link. In my theme, edit comes before reply. How do you change the order of the printed links?

A: 

Try creating a comment preprocess function in template.php in your theme. That should give you access to the $links variable and allow you to re-order the elements.

stevec
Good idea. I tried using unset ($links['comment_reply']); in the preprocess function, but it didn't work.
Toxid
A: 

Check out hook_link_alter() - it allows you to manipulate the links before they get rendered, e.g. remove some or change the order.

Henrik Opel
A: 

This function will reverse the order of comment links. Put it in your template.php (also after adding the function empty your site caches and visit /admin/build/themes once to make sure this function is picked up in the theme registry):


function phptemplate_links($links, $attributes = array('class' => 'links')) {
  if (isset($links['comment_edit'])) {
    krsort($links); // or ksort if you want to order your links the other way
  }
  return theme_links($links, $attributes);
}
dazweeja