Skip to main content
Question Protected by CommunityBot
replaced http://drupal.stackexchange.com/ with https://drupal.stackexchange.com/
Source Link

Contextual filter -> Comment NID (Content ID from URL) (Shown herehere)

Contextual filter -> Comment NID (Content ID from URL) (Shown here)

Contextual filter -> Comment NID (Content ID from URL) (Shown here)

Notice removed Authoritative reference needed by Dominic Woodman
Bounty Ended with Nikos Tsagkas's answer chosen by Dominic Woodman
Tweeted twitter.com/#!/StackDrupal/status/558615197368463361
added 469 characters in body
Source Link
Dominic Woodman
  • 2.2k
  • 4
  • 36
  • 60

UPDATE

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.

ORIGINAL WORKINGS

What I've tried to do so far -- Show: Settings: Parent relationship

What I've tried to do so far -- Show: Settings: Parent relationship

UPDATE

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.

ORIGINAL WORKINGS

What I've tried to do so far -- Show: Settings: Parent relationship

added 567 characters in body
Source Link
Dominic Woodman
  • 2.2k
  • 4
  • 36
  • 60

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?

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

enter image description here

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 Comment: Thread.

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?

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?

What I've tried to do so far

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

enter image description here

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).

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?

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

enter image description here

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 Comment: Thread.

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?

Notice added Authoritative reference needed by Dominic Woodman
Bounty Started worth 50 reputation by Dominic Woodman
improved clarity in last para
Source Link
Dominic Woodman
  • 2.2k
  • 4
  • 36
  • 60
Loading
Source Link
Dominic Woodman
  • 2.2k
  • 4
  • 36
  • 60
Loading