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

Page.find() - how to exclude modular pages?

Started by Muut Archive 10 years ago · 2 replies · 442 views
10 years ago

Hi,

Grav version : 1.1rc3

I want to publish the latest content (whatever the content type) but so far it includes also some modular pages. Is there a way to exclude modular pages from the page list ?

TWIG
 {% for page in page.find('/').children.order('date', 'desc').slice(0, 5) %}
            <div class="media-object">
                {% set showcase_image = page.media.images|first.resize(100,100).url %}
                {% if showcase_image %}
                <div class="media-object-section">
                    <img alt="{{ page.title }}" src="{{ showcase_image }}" />
                </div>
                {% endif %}

                <div class="media-object-section">
                    <h5><a href="{{ page.url }}">{{ page.title }}</a></h5>

                </div> 
            </div>
            {% endfor %}

I tried to use dump(page) to get more data but I can't see on what I could filter to exclude modular content.

Thanks,
Nicolas

10 years ago

The .children method returns a Collection of pages. You can then use the .nonModular method to filter out modular pages:

TWIG

{% for page in page.find('/').children.nonModular.order('date', 'desc').slice(0, 5) %}
---

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 1369 9 years ago
Archive · by Muut Archive, 9 years ago
2 942 9 years ago
Archive · by Muut Archive, 9 years ago
2 4069 9 years ago
Archive · by Muut Archive, 9 years ago
1 2960 9 years ago
Archive · by Muut Archive, 9 years ago
3 1125 9 years ago