2010-01-14 64 views
0

即時通訊在這裏與一個討厭的問題。更改Drupal 6中的線程評論標記

Drupal的處理意見,使用戶能夠顯示thems選擇剛剛在4種方式:Flat list - collapsedFlat list - expandedThreaded list - collapsedThreaded list - expanded

進出口使用的最後一個,就是提供了一個標記,如:

<div class="comment"> 
    <!-- comment's content --> 
</div> 
<div class="indented"> 
    <!-- next comment is an 'answer' to the previous comment! --> 
    <div class="comment"> 
     <!-- comment's content --> 
    </div> 
</div> 

但我想有「父」註釋的相同DOM元素裏面的「孩子」的評論。 因此,舉例來說,像這樣:

<div class="comment"> 
    <!-- comment's content --> 
    <div class="indented"> 
     <!-- next comment is an 'answer' to the previous comment! --> 
     <div class="comment"> 
      <!-- comment's content --> 
     </div> 
    </div> 
</div> 

爲了有一個標記,讓我帶螺紋評論爲this blog(使用WordPress)一樣。

它使用像標記:

<ul> 
    <li> 
     <div class="comment> 
      <!-- comment's content --> 
     </div> 
     <ul class="children"> 
      <li> 
       <div class="comment> 
        <!-- comment's content --> 
       </div> 
      </li> 
     </ul> 
    </li> 
</ul> 

那麼,什麼是drupalish辦法做到這一點(更好,如果我需要的所有變化都在template.php文件或模板文件)?

回答

1

comment_render()似乎在內部做一切。所以你需要重寫這個。不幸的是,如果您使用node_show()呈現節點,則comment_render將自動運行(不是通過可重寫的主題函數),因此您需要做很多工作才能實現您想要的效果。

首先,你將不得不使用hook_nodeapi說服Drupal核心不存在註釋(talk module做到這一點)

function talk_nodeapi(&$node, $op) { 
    switch ($op) { 
    case 'load': 
     if (talk_activated($node->type) && arg(0) == 'node' && !arg(2)) { 
     // Overwrite setting of comment module and set comments for this node to disabled. 
     // This prevents the comments of being displayed. 
     $output['comment_original_value'] = $node->comment; 
     $output['comment'] = 0; 
     return $output; 
     } 
     break; 
    } 
} 

然後你需要編寫自己的實現comment_render(築巢),並調用節點呈現後(可能在您的模板頁面或預處理函數中)。

+0

+1這是很多工作,但絕對是這樣做的方式。 – googletorp 2010-01-14 15:33:54