您的位置:首页 > Web前端 > Node.js

如何在node节点的评论下面添加想要…

2012-11-29 14:20 417 查看
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节点的评论下面了。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: