drupal implements methods for adding content under comments on node nodes
This article illustrates an example of how drupal implements adding content under comments on node nodes. Share with you for your reference. The specific implementation method is as follows:
The comment node display for Node in drupal is controlled by the following function. This function is in node.module and looks like this:
$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;
}
Here's an example of how to add something to a comment on a node node.
First, use the hook_nodeapi hook to write the content to be loaded into the node object. This function is in popularterms.module, and it looks like this:
switch ($op) {
case 'load':
if($node->type == 'story'){
$node->popularterms_html_content = popularterms_html_content1();
}
break;
}
}
Then write the above addition below the node display of the node_show function.
As follows:
$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);
// Comment on "Recent Popular content" added below -jason20080923
$output .= $node->popularterms_html_content;
return $output;
}
The content that needs to be added is displayed under the comments of the node node.
I hope this article will help you with your drupal secondary development.
Related article
-
Drupal CMS can produce 16 types of websites
I don't know. Drupal is amazing. Many people who use CMS content management systems will probably know about a foreign CMS system: Drupal. In our traditional imagination, CMS can do not only content article stations, but also picture stations2010-01-24 -
Drupal enables caching and Gzip compression setup methods
Enable caching and Gzip compression transfer for pages and static resources.2010-01-24 -
drupal module development analysis
drupal module development analysis, easy to want to drupal module development friends2012-12-06 -
The drupal custom form calls the autocomplete main tag implementation code
drupal custom form call autocomplete main tag implementation code, need friends can refer to the next2012-12-06 -
drupal import image implementation method
This article mainly introduces the implementation method of drupal import pictures, which is a very practical skill, and the friends who need it can refer to it2014-11-03 -
drupal import data implementation method
This article mainly introduces the implementation method of drupal import data, which is very practical value, and the friends who need it can refer to it2014-11-03 -
drupal ip_address function usage analysis
This article mainly introduces the use of ip_address function in drupal, and analyzes the method of obtaining server IP address behind rev proxy. It has certain reference value, and the friends who need it can refer to it2014-11-03 -
drupal implements methods that output clickable table headers to sort tables
This article mainly introduces the method of drupal to achieve the output of clickable table header sorting table, including the definition of the table, SQL statements, table content and the generation of HTML files, etc., need friends can refer to the next2014-11-03 -
Overview of the drupal file system
This article mainly introduces the drupal file system, describes the classification of the drupal file system, focuses on the use of the hook function, the need for friends can refer to2014-11-03 -
The tabs in the drupal template (page.tpl) have no user and password solutions
This article mainly introduces the drupal template (page.tpl) in the tabs no user and password solution, drupal template development has a certain reference value, the need of friends can refer to2014-11-03
Latest comments