I'm trying to display the comments on my nodes in a view rather than using drupals default comments rendering.
Is it possible to display a comment view on a node, which also renders the comments with replies, rather than rendering every comment (including replies) as a top level comment?
How would you setup views to do this?
I've successfully setup views, so that it renders comments and replies in the correct order.
You have to set:
Relationship -> Comment: Parent Comment Sort Criteria -> Thread (desc) Sort Criteria -> (Parent Comment) Comment: Post date (asc)
However the pager still counts every single comment reply as an item, so it is prone to cutting off threads in the middle and ideally I'd still like to page it.
What I've tried to do so far -- Show: Settings: Parent relationship
Getting the top level comments was reasonably easy, I created a view block which displays comments and then added:
Contextual filter -> Comment NID (Content ID from URL) (Shown here)
This gives a me a view block which will display comments. However all the comments are rendered as top level comments (no indented markup)
I needed the parent relationship, so I added a second relationship (comment views by default have a
Comment: Content relationship),
Comment: Parent Comment
And then under Format: Show: Settings, I enabled:
Relationship: Parent Comment
Unfortunately on loading the node, this causes several PHP errors. views_plugin_row_comment_view.inc has a pre_render function and for some reason changing the Relationship: Parent Comment causes none of the CID's to load in the pre-render function and so it spits out all the horrible errors you see below. How am I setting this up wrong?
Undefined property: stdClass::$cid in views_plugin_row_comment_view->pre_render() (line 79 of ... sites\all\modules\views\modules\comment\views_plugin_row_comment_view.inc Warning: array_flip(): Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->load() (line 173 of C:\xampp\htdocs\basic\includes\entity.inc). Notice: Undefined index: in template_preprocess_views_view_row_comment() (line 645 of C:\xampp\htdocs\basic\sites\all\modules\views\modules\comment.views.inc). Notice: Trying to get property of non-object in template_preprocess_views_view_row_comment() (line 646 of C:\xampp\htdocs\basic\sites\all\modules\views\modules\comment.views.inc). Notice: Undefined index: in template_preprocess_views_view_row_comment() (line 646 of C:\xampp\htdocs\basic\sites\all\modules\views\modules\comment.views.inc). Notice: Trying to get property of non-object in template_preprocess_views_view_row_comment() (line 650 of C:\xampp\htdocs\basic\sites\all\modules\views\modules\comment.views.inc). EntityMalformedException: Missing bundle property on entity of type comment. in entity_extract_ids() (line 7729 of C:\xampp\htdocs\basic\includes\common.inc).
What I've tried to do so far -- Sort: Comment Threading
I took a look at the following sandbox module and according to the issue thread it was based on https://drupal.org/node/1039494, apparently it was solved ages ago by adding in a sort criteria
I tried adding this and setting the relationship to parent comment but this also had no effect, the comments still remained in separate rows. Has anyone had success with this method?