Page.find('/') does not return all pages whatever the conent type?

Hi,

I have the following structure:

.
├── 01.home
│   ├── modular.fr.md
│   ├── _offres
│   │   └── offer.fr.md
│   ├── _showcase
│   │   ├── bandeaux_laser.png
│   │   ├── bandeaux_miniji.png
│   │   ├── idfalamer.png
│   │   ├── IMG_0030.jpg
│   │   ├── IMG_0032.jpg
│   │   └── showcase.fr.md
│   └── _text
│       └── text.fr.md
├── 02.le_club
│   ├── 01.presentation 
│   │   └── default.fr.md
│   ├── 02.le-bureau
│   │   └── default.fr.md
│   ├── default.fr.md
│   ├── default.md
│   ├── les-tarifs
│   │   └── default.fr.md
│   └── presentation
│       └── default.fr.md
├── 03.Agenda
│   ├── calendar.fr.md
│   ├── event-1
│   │   ├── event.fr.md
│   │   └── IMG_0032.jpg
│   └── event-2
│       ├── event.fr.md
│       └── IMG_0030.jpg
├── 04.initiation_et_loisirs
│   ├── 01.stages jeunes
│   │   └── default.fr.md
│   ├── 02.stages-adultes
│   │   └── default.fr.md
│   ├── 03.locations
│   │   └── default.fr.md
│   ├── 04.voile-scolaire
│   │   └── default.fr.md
│   ├── 05.voile-entreprise
│   │   └── default.fr.md
│   ├── 06.offres-groupe
│   │   └── default.fr.md
│   └── default.md
├── 05.perfectionnement_et_regate
│   ├── 01.ecole_de_sport
│   │   ├── default.md
│   │   ├── optimiste-bic-laser
│   │   │   └── default.fr.md
│   │   └── planche-a-voile
│   │       └── default.fr.md
│   ├── 02.equipes_regates_jeunes
│   │   ├── 420
│   │   │   └── default.fr.md
│   │   ├── default.md
│   │   ├── habitable
│   │   │   └── default.fr.md
│   │   ├── laser
│   │   │   └── default.fr.md
│   │   ├── optimist
│   │   │   └── default.fr.md
│   │   └── planche-a-voile
│   │       └── default.fr.md
│   ├── 09.animations_du_club
│   │   ├── animation-du-samedi
│   │   │   └── default.fr.md
│   │   ├── default.md
│   │   ├── habitable
│   │   │   └── default.fr.md
│   │   ├── handivoile
│   │   │   └── default.fr.md
│   │   ├── miniji
│   │   │   └── default.fr.md
│   │   └── vrc
│   │       └── default.fr.md
│   └── default.md
├── 06.licence-and-inscriptions
│   └── default.fr.md
├── 07.contact
│   └── form.md
├── 07.formation
│   └── default.fr.md
├── 08.gallerie
│   └── default.fr.md
├── 09.blog
│   ├── 01.test-blog
│   │   ├── IMG_0032.jpg
│   │   └── item.fr.md
│   ├── 02.test-blog2
│   │   ├── IMG_0030.jpg
│   │   └── item.fr.md
│   └── blog.fr.md
├── 10.events
│   └── events.fr.md
└── 10.petites-annonces
    └── default.fr.md

However, for the code:

{% for page in page.find('/').children.nonModular.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 don"t have any content whereas many content so far is elligible, being a default or a blog post or an event content type.

If I remove the nonModular thing, I have the modular page which shows up.

I can’t use collections here I think as it’s part of my modular page and my collection is user for something else.

Thanks,
Nicolas

it’s just a small problem with your for loop, replace page with child and it should works;

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

oh, wait, I was too quick, your syntax is correct actually. But you are telling twig to look for nonmodular children of your home page, which is probably set to 01.home, and this page does not have children! if you replace your page find with page.find(’/agenda’) or page.find(’/initiationetloisir’) you should have results

If you need to start from root and get first child pages, I believe you dont need to use find as the object pages contains those pages already.

{% for child in pages.children.nonModular.slice(0, 5) %} this will go one level only.

or try {% for child in pages.descendants.nonModular.slice(0, 5) %} to get them all pages in your site.

not tested, :stuck_out_tongue:

Hi,

Indeed, the correct syntax was the one of HugoAvila:

{% for child in pages.children.nonModular.slice(0, 5) %}

The syntax of paulmassendari produced the same output as I :wink:

Thanks !