I'm using views to display the fields of nodes. I prefer to use fields because it allows me to use relationships (bring in author profile picture etc.). Adding the Content: Comments field shows the list of comments as well as the comment form for each node. However, when hiding and rewriting the result/and or using the replacement pattern for Content: Comments, the comment form disappears and only the comment list remains.

What methods can I use to display the comment form for each node in a list of nodes view when using fields?

有帮助吗?

解决方案

However, when hiding and rewriting the result/and or using the replacement pattern for Content: Comments, the comment form disappears and only the comment list remains.

It's due to a Views UI bug as I was able to replicate the issue on a fresh install.

A workaround you can do is to do the re-writing via template file rather than via UI.

In your theme's /templates folder add:

views-view-fields--view-name--machine-name.html.twig

and print the view fields there

{{ fields.title.content }} {# title field #}

{{ fields.comment.content }} {# comment field #}

{{ fields.field_name.content }} {# some other field #}

Flush all caches so template gets pickedup.

许可以下: CC-BY-SA归因
scroll top