I am trying to render comment tree using twig macro but keep getting following error:
"Neither the property "comments" nor one of the methods "comments()", "getcomments()"/"iscomments()"/"hascomments()" or "__call()" exist and have public access in class "Doctrine\ORM\PersistentCollection"."
If there is additional info needed, I am at disposal.
Br,
{% macro render_comment(comment) %}
<li id="comment-{{ comment.id }}">
<span>
{{ comment.author.fullName }}
{{ 'post.commented_on'|trans }}
{{ comment.publishedAt|format_datetime('medium', 'short', '', 'UTC') }}
</span>
{{ comment.content|markdown_to_html|sanitize_html }}
<a href="#comment_content" data-reply data-id="{{ comment.id }}">
{{ 'action.submit_reply'|trans }}
</a>
{% if comment.children is not empty %}
<ul>
{% for child in comment.children %}
{{ _self.render_comment(child) }}
{% endfor %}
</ul>
{% endif %}
</li>
{% endmacro %}
{% macro render_comment_list(comments) %}
{% for comment in comments %}
{% if comment.parent is null %}
{{ _self.render_comment(comment) }}
{% endif %}
{% else %}
{{ 'post.no_comments'|trans }}
{% endfor %}
{% endmacro %}
You need to pass
commentstoo:and make sure that when you render this template, you expose
commentsproperly so it can reach them.EDIT
As per the comment section
was the solution.