开发者

Drupal 7 Get Comments Of Node

开发者 https://www.devze.com 2023-04-13 00:28 出处:网络
Is there an easy way to get the comment开发者_StackOverflows of a node programmatically in Drupal 7?Check out the function comment_get_thread(), it may be of use to you.If you don\'t want to write a c

Is there an easy way to get the comment开发者_StackOverflows of a node programmatically in Drupal 7?


Check out the function comment_get_thread(), it may be of use to you.


If you don't want to write a code then you can override the node with The panel's node template and by creating a variant in it you can add comment thread in the variant. And I think it is very easier way to do this.


In Drupal 7 you can use the below code to get all the comments of a node using node ID

$nid = 2; // node ID
    $comments = db_select('comment')
              ->fields('comment', array('name','subject'))
              ->condition('nid', $nid, '=')
              ->execute()
              ->fetchAssoc();
    foreach($comments as $comment) {
        print your comments here
    }

In Drupal 6 you can use the comment_render() ;

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号