drupal实现在node节点的评论下面添加内容的方法

本文实例讲述了drupal实现在node节点的评论下面添加内容的方法。分享给大家供大家参考。具体实现方法如下:

drupal中node的评论节点显示是由下面的函数来控制的。
这个函数在node.module里面,如下所示:

function node_show($node, $cid) {
$output = node_view($node, FALSE, TRUE);
if (function_exists('comment_render') && $node->comment) {
$output .= comment_render($node, $cid);
}
// Update the history table, stating that this user viewed this node.
node_tag_new($node->nid);
return $output;
}

下面我以实例说明如何在node节点的评论下面添加一些内容。
首先用hook_nodeapi钩子把需要加载的内容,写到node对象里。这个函数在popularterms.module里面,如下:

function popularterms_nodeapi(&$node, $op, $teaser = NULL, $page = NULL) {
switch ($op) {
case 'load':

if($node->type == 'story'){
$node->popularterms_html_content = popularterms_html_content1();
}
break;
}

}

然后把上面添加的内容写到node_show函数的节点显示的下面。
如下所示:

function node_show($node, $cid) {
$output = node_view($node, FALSE, TRUE);
if (function_exists('comment_render') && $node->comment) {
$output .= comment_render($node, $cid);
}
// Update the history table, stating that this user viewed this node.
node_tag_new($node->nid);
//评论下面添加的“最近流行的内容”-jason20080923
$output .= $node->popularterms_html_content;
return $output;
}

这样需要添加的内容就显示到了node节点的评论下面了。

希望本文所述对大家的drupal二次开发有所帮助。