3

I would like to display comments of the current node in a view. The reason for doing so is that I want the comments to be neatly displayed in a table and views seems to be an easiest way to do so than messing with theme template etc. (I am new to drupal)

I have created a comment view and selected comment: nid as a filter selector. How do I provide the "current NID" as the argument for the filter? I have tried Comment:nid is equal to "current" but this does not work.

Any suggestion?

1 Answer 1

6

You need a contextual filter. In your view, remove comment:nid from the Filter Criteria.

Next, on the far right, under "Advanced", add a "Contextual Filters" and select comment: nid there.

enter image description here

In the configuration options, under WHEN THE FILTER IS NOT AVAILABLE, select "Provide Default Value". From the Type dropdown, select "Content ID from URL".

enter image description here

Click Apply, save your view, and add the block as normal.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.