简体   繁体   English

我如何在Drupal 7中渲染节点注释?

[英]How would I render a nodes comments in Drupal 7?

I'm doing the following to load and render a node via ajax: 我正在执行以下操作以通过ajax加载和渲染节点:

$node = node_load($id);
$node_view = node_view($node);
drupal_render($node_view);

This works perfectly for displaying the node, BUT the comments and comment form are missing. 这非常适合显示节点,但是缺少注释和注释表单。 How would I add the comments and comment form to either $node or $node_view so they are rendered by drupal_render? 如何将评论和评论表单添加到$ node或$ node_view中,以便它们由drupal_render呈现? node.tpl.php is being called to render the node FYI ;) 正在调用node.tpl.php来渲染节点FYI;)

Thanks!!! 谢谢!!!

Looking at the comment module (specifically comment_node_view() ) it should be added by default but if not this should work: 查看注释模块(特别是comment_node_view() ),默认情况下应添加该模块,但如果不行,则应起作用:

$node = node_load($id);
$node_view = node_view($node);

$node_view['comments'] = comment_node_page_additions($node);

echo drupal_render($node_view);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM