簡體   English   中英

Drupal,如何從Webform頁面上刪除登錄或評論鏈接?

[英]Drupal, how to Remove Login or comment link from webform pages?

我要刪除Login or register to post comments在創建Web表單的頁面上Login or register to post comments文本; 關於如何使用hook_link_alter()有什么建議嗎?

此代碼位於theme_comment_post_forbidden()函數下的comment.module文件中。

如果您使用的是Drupal 7,則可以使用hook_node_view_alterhook_entity_view_alter來修改顯示的內容。

function foo_node_view_alter (&$build) {

  if ($build['#node']->type == 'webform') {
    // remove login or register to post comments
    unset($build['links']['comment']['#links']['comment_forbidden']);
    // remove add comments
    unset($build['links']['comment']['#links']['comment_add']);
  }

}

如果要在Drupal 6中使用hook_link_alter,請在自定義模塊中使用此代碼

function comment_link_alter (&$links, $node) {

  if ($node->type == 'webform') {
    // remove register or login to post comments
    unset($links['comment_forbidden']);
    // remove add a comment
    unset($links['comment_add']);
  }

}

如果使用的是內容類型,則可以覆蓋主題。

  1. 將模板文件“ /modules/node/node.tpl.php”復制到主題的“ templates”目錄中
  2. 重命名該文件,將其稱為“ node--NODETYPE-tpl.php”(在“ node”之后的兩個連字符)。 例如,“ node--book-tpl.php”代表“ book”內容類型。
  3. 注釋掉最后兩行(或刪除它們):

     // print render($content['links']); // print render($content['comments']); 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM