For context: in my template file node--some-node.html.twig i have a grid of items which have a custom comment form on them. The form creates a comment through an API. The form passes the ID of the grid item it is under to the API and the created comment then has a field_profile_id with the item's id in it. Now, in the template file I need to output JUST the comments that belong to that grid item.
When I write this into the template file:
{{ content.field_comments }}
i get the output of all the comments that belong to this node and underneath I get the comment form (which I don't need). Ideally I would like to do everything in the same template file, so I could do something like this:
{% if entity.nid.value == content.field_comments.someComment.field_profile_id %}
{# output the comment here #}
{% endif %}
Here the entity.nid.value
is the node id of the grid items I was talking about earlier.
EDIT: Theoretically what I need to do is:
- Iterate through all possible comments for this node.
- Check if comment has some ID value (that a grid item might have)
- If the IDs match, print out the comment, if it doesn't skip it