简体   繁体   English

评论$ links在drupal中的顺序

[英]Comment $links order in drupal

In the comment.tpl, $links is printed to show the reply and edit link. 在comment.tpl中,将打印$ links以显示答复和编辑链接。 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. 尝试在主题中的template.php中创建注释预处理功能。 That should give you access to the $links variable and allow you to re-order the elements. 这应该使您可以访问$ links变量,并允许您对元素进行重新排序。

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): 将其放在您的template.php中(也添加了功能后,清空网站缓存并访问/ admin / build / themes一次,以确保在主题注册表中选择了此功能):


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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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