sonata-project/SonataNewsBundle — Issue #25: Unrecognized field: created_at while trying to get number of comments
Author: reverso73
Created: 2011-10-18 13:49:36+00:00
State: open

Hello,

I try to display on my "archive" page the number of comments for each post.
When I try to access to the property like this in archive.html.twig

>{% for post in pager.getResults() %}
> {{ post.getComments|length }}
>{% else %}
> {{ 'no_post_found'|trans({}, 'SonataNewsBundle') }}
>{% endfor %}

I get :
>An exception has been thrown during the rendering of a template ("Unrecognized field: created_at")

Do you have a trick to get the number of comments, validated if possible, for each post ?

Thanks