欢迎各位兄弟 发布技术文章

这里的技术是共享的

You are here

Drupal7 d7 Get Comments Of Node 根据节点得到评论 有大用

Is there an easy way to get the comments of a node programmatically in Drupal 7?



1)

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


2)

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();  //应该使用 fetchAll吧
    foreach($comments as $comment) {
        print your comments here
    }

In Drupal 6 you can use the comment_render() ;


来自 https://stackoverflow.com/questions/7740026/drupal-7-get-comments-of-node



普通分类: