简体   繁体   中英

Comment $links order in drupal

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?

检出hook_link_alter() -它允许您在链接呈现之前对其进行操作,例如,删除一些链接或更改其顺序。

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.

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);
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM