DrupalX

Extension
Framework

count

This will return the number of items in the list. Please note that you can of course either call this method directly or implicitly by using "count($list)" in PHP or "list | length" in Twig, respectively.

{% set list=Node::queryAll({category:'sports'}) %}

The "sports" category has the following {{list | length}} items :

<ul>
  {% for item in list %}
    <li>{{ item.$title }}</li>
  {% endfor %}
</ul>