2012-02-13 67 views

回答

4

此代碼駐留在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

在使用此代碼,你可以過騎的主題。

  1. 複製模板文件「/modules/node/node.tpl.php」到你的主題的「模板」目錄
  2. 重命名文件,稱這是「節點 - NODETYPE-tpl.php」(這是「節點」之後的兩個連字符)。例如,'book-tpl.php'爲'book'內容類型。
  3. 註釋掉最後兩行(或刪除):

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