Issue first element of foreach loop

I have a very odd issue only concerning the first item of my foreach loop.

The structure is this:

content/mypage/

Then within that page I have 5 sections

1_section
2_section
3_section

… and so on

Within each of this section folders I have the text files stored

section.en.txt
section.fr.txt
section.nl.txt

So I am looping through the content of this files and this works perfectly for all elements except for the first one.

This one does not return the fields I added in the txt files and which are being printed in this section’s template file.

My code:

foreach ($sections as $section) :
    <div>
        <?= $section->image() ?>
        <h3><?= $section->title() ?></h3>
        <p><?php echo $section->intro() ?></p>
        <a><?= $section->buttonAft() ?></a>
        <a><?= $section->buttonTvl() ?></a>
    </div>
<?php endforeach; ?>

In the .txt file all fields are present (title, intro, buttonAft, buttonTvl) and in the 4 last sections this content is printed correctly, only in the first item it isn’t.

Any tips where my mistake could be?

Thanks!

How is $sections defined?

Do you create your pages manually or via the Panel?

$sections = $page->children();

The pages are created manually.

Hm, and do all your folders have different folder names (apart from the number)? You can’t have a structure like the one you posted above:

1_section
2_section
3_section

This would end up with the first 2 ignored.

Yes the folders all have different names (it was just to mention the structure), and it’s the same way I did with other pages and there I didn’t had any problems.

So its very odd …

And all subpages have all three text files with the language keys? And all files are readable?

What do you get if you do a

dump($page->children());

Is the first element missing from this dump as well?

No that is the weird part, all are available in dump …

And do you get 5 section divs in your rendered HTML, with only the content missing from the first?

Yes indeed, the html is rendered but just with the content missing

The I would try and recreate those files, maybe there is some weird character in there or the file got corrupted or whatever.

I had already renamed them but that didn’t solve the issue, deleting and recreating it fixed the issue!
Thanks!