drupal實(shí)現(xiàn)在node節(jié)點(diǎn)的評(píng)論下面添加內(nèi)容的方法
發(fā)布時(shí)間:2014-11-04 10:30:37 作者:佚名
我要評(píng)論

這篇文章主要為大家介紹了drupal實(shí)現(xiàn)在node節(jié)點(diǎn)的評(píng)論下面添加內(nèi)容的方法,涉及相關(guān)函數(shù)的修改與hook函數(shù)的使用,具有一定的借鑒價(jià)值,需要的朋友可以參考下
本文實(shí)例講述了drupal實(shí)現(xiàn)在node節(jié)點(diǎn)的評(píng)論下面添加內(nèi)容的方法。分享給大家供大家參考。具體實(shí)現(xiàn)方法如下:
drupal中node的評(píng)論節(jié)點(diǎn)顯示是由下面的函數(shù)來控制的。
這個(gè)函數(shù)在node.module里面,如下所示:
復(fù)制代碼
代碼如下: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;
}
$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;
}
下面我以實(shí)例說明如何在node節(jié)點(diǎn)的評(píng)論下面添加一些內(nèi)容。
首先用hook_nodeapi鉤子把需要加載的內(nèi)容,寫到node對(duì)象里。這個(gè)函數(shù)在popularterms.module里面,如下:
復(fù)制代碼
代碼如下: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;
}
}
switch ($op) {
case 'load':
if($node->type == 'story'){
$node->popularterms_html_content = popularterms_html_content1();
}
break;
}
}
然后把上面添加的內(nèi)容寫到node_show函數(shù)的節(jié)點(diǎn)顯示的下面。
如下所示:
復(fù)制代碼
代碼如下: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);
//評(píng)論下面添加的“最近流行的內(nèi)容”-jason20080923
$output .= $node->popularterms_html_content;
return $output;
}
$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);
//評(píng)論下面添加的“最近流行的內(nèi)容”-jason20080923
$output .= $node->popularterms_html_content;
return $output;
}
這樣需要添加的內(nèi)容就顯示到了node節(jié)點(diǎn)的評(píng)論下面了。
希望本文所述對(duì)大家的drupal二次開發(fā)有所幫助。
相關(guān)文章
- 真是不看不知道,Drupal 真奇妙。很多使用CMS內(nèi)容管理系統(tǒng)的人可能都會(huì)知道一款國(guó)外的CMS系統(tǒng):Drupal 。在我們傳統(tǒng)的想象中CMS除了能做內(nèi)容文章站外,其他還有圖片站,分2010-01-24
- 對(duì)頁(yè)面和靜態(tài)資源的啟用緩存和Gzip壓縮傳輸.2010-01-24
- drupal模塊開發(fā)分析,方便想要drupal模塊開發(fā)的朋友2012-12-06
drupal 自定義表單調(diào)用autocomplete主標(biāo)簽實(shí)現(xiàn)代碼
drupal 自定義表單調(diào)用autocomplete主標(biāo)簽實(shí)現(xiàn)代碼,需要的朋友可以參考下2012-12-06drupal導(dǎo)入圖片的實(shí)現(xiàn)方法
這篇文章主要為大家介紹了drupal導(dǎo)入圖片的實(shí)現(xiàn)方法,是非常實(shí)用的技巧,需要的朋友可以參考下2014-11-03drupal導(dǎo)入數(shù)據(jù)的實(shí)現(xiàn)方法
這篇文章主要為大家介紹了drupal導(dǎo)入數(shù)據(jù)的實(shí)現(xiàn)方法,非常具有實(shí)用價(jià)值,需要的朋友可以參考下2014-11-03- 這篇文章主要為大家介紹了drupal中的ip_address函數(shù)用法,實(shí)例分析了rev proxy后面的服務(wù)器IP地址的獲取方法,具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2014-11-03
drupal實(shí)現(xiàn)輸出可點(diǎn)擊表頭排序表格的方法
這篇文章主要為大家介紹了drupal實(shí)現(xiàn)輸出可點(diǎn)擊表頭排序表格的方法,包括了表的定義、SQL語句、表內(nèi)容及生成HTML文件等,需要的朋友可以參考下2014-11-03- 這篇文章主要為大家介紹了drupal文件系統(tǒng),講述了drupal文件系統(tǒng)的分類,重點(diǎn)講述了鉤子函數(shù)的用法,需要的朋友可以參考下2014-11-03
drupal模板(page.tpl)中的tabs無用戶與密碼的解決方法
這篇文章主要為大家介紹了drupal模板(page.tpl)中的tabs無用戶與密碼的解決方法,在drupal模板開發(fā)中具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2014-11-03