首页 > 电脑专区 > CMS教程 > 其它cms >

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

来源:互联网 2023-03-14 12:48:42 116

本文实例讲述了drupal实现在node节点的评论下面添加内容的方法。分享给大家供大家参考。具体实现方法如下:RXw办公区 - 实用经验教程分享!

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节点的评论下面了。RXw办公区 - 实用经验教程分享!

希望本文所述对大家的drupal二次开发有所帮助。RXw办公区 - 实用经验教程分享!

以上方法由办公区教程网编辑摘抄整理自互联网可供大家参考!RXw办公区 - 实用经验教程分享!


标签: Drupal

办公区 Copyright © 2016-2023 www.bgqu.net. Some Rights Reserved. 备案号:湘ICP备2020019561号统计代码