Skip to content
Grav 2.0 is officially stable. Read the announcement →
Archive

How to count modular visible (short way)

Started by Muut Archive 9 years ago · 2 replies · 492 views
9 years ago

I need to know how many modulars are visibles, i find a way with a loop but trying to find a "short way" like with pages.children.visible|length

TWIG

{# COUNT PAGES VISIBLE #}
{% set page_visible = pages.children.visible  %}
{% set totalpagevisible = page_visible|length %}

{% set totalmodularvisible = 0 %}
{% for modular in page.collection() %}
   {% if modular.header.visible %}
      {% set totalmodularvisible = totalmodularvisible + 1 %}
   {% endif %}
{% endfor %}
---
9 years ago
TXT
page.collection.modular|length

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 1333 9 years ago
Archive · by Muut Archive, 9 years ago
2 924 9 years ago
Archive · by Muut Archive, 9 years ago
2 4055 9 years ago
Archive · by Muut Archive, 9 years ago
1 2933 9 years ago
Archive · by Muut Archive, 9 years ago
3 1110 9 years ago