cms教程
cms教程 > drupal > 详情
drupal实现在node节点的评论下面添加内容的方法
2020-11-25 09:30 蚂蚁资源网 阅读:121
大家好,今小编要介绍的是关于drupal实现在node节点的评论下面添加内容的方法的相关内容,多方面分析说明,感兴趣朋友的可以参考学习。

关键词:Drupal  

本文实例讲述了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二次开发有所帮助。


以上就是drupal实现在node节点的评论下面添加内容的方法的全部内容,希望可以帮助到您。感谢对蚂蚁资源网的支持。
(责任编辑:崔伞

版权声明:文章内容是蚂蚁资源网小编精心整合原创的,素材来源于互联网,如无意侵犯到您的权益,请联系网站客服核实版权信息,以便及时删除。
上一篇 下一篇

订单

搜索
蚂蚁资源网

购物车

我的