I copied the code

{% set count = '[' ~ flagcount(flag, flaggable) ~ ']' %}

in flag.html.twig and I copy this file into the templates folder of my theme (I did not cache it).

But after I do not know how to do it. Currently to display the flag link in node.html.twig I put the following code :

{{ content.flag_like_node }}

How to add the number of flag ?

I tested the following code and none works

{{ content.flag_like_node_count }}
{{ content.flag_like_node.count }}
{{ count }}

Comments

zenimagine created an issue. See original summary.

socketwench’s picture

Status: Active » Postponed (maintainer needs more info)

I don't believe you can actually use the flagcount plugin in a node template at all. The flagcount plugin requires the flag object, but it's not available in the node template. Furthermore, the flag field isn't a real field, so there's no way to access the flag object through the node or content variables.

It *is* available from the flag template though. It sounded like you added the flag template to your theme, did you add the flagcount code there?

zenimagine’s picture

Ok so what is the sub module "count" for? How does it work ?

On my node I want to show:

- the flag link with {{ content.flag_like_node }} OK
- and below the number of flag on the node with ???

How to do this ?

Thank you

zenimagine’s picture

Status: Postponed (maintainer needs more info) » Active
zenimagine’s picture

Component: Flag core » Documentation
zenimagine’s picture

can someone explain to me how the sub module works to conquer the flag? there is nothing in the documentation

zenimagine’s picture

Please, who can explain to me how this module works? Can not get flag count in twig.

There is no documentation.

zenimagine’s picture

What is the purpose of this module and how does it work?

zenimagine’s picture

Priority: Normal » Major
zenimagine’s picture

Component: Documentation » Flag core
zenimagine’s picture

Status: Active » Closed (works as designed)
tepelena’s picture

zenimagine
I am having the same issue. There is not much information on how to show total flag count. How did you do it?

PrajaktaN’s picture

facing the same issue. please let me know how it works

chucksimply’s picture

Same here! Has anyone got the count working via this sub module? Or any other way?

chucksimply’s picture

So for all still wondering... {{ count }} MUST go in flag.html.twig along with {% set count = '[' ~ flagcount(flag, flaggable) ~ ']' %}. I couldn't get the flag count to work directly in the node.html.twig.

Just know you can also specify the flag template to your specific flag if you need to narrow it down... something like flag--like-node.html.twig.

Hope this helps some.