Image Grid: Fetch 6 Last Projects with Bootstrap

Yes, that should work as well.

Or just:

$projects = page('projekte')->children()->filterBy('hasImages', true)->limit(6);
2 Likes

Ah! Love this!
It’d be brilliant to have this example in the filterBy docs!

I should probably reread my own tutorials or do more brain exercises…:blush:

Or force yourself to a strict curfew :stuck_out_tongue:

Maybe I just love the filter with callback so much …:heart_eyes:

That’s another point I can’t solve so far… :slight_smile:

This is my site structure:

    1-projekte
          1-corporate-design
          2-editorital-design
          3-testprojekt
          projekt
               1-cd1
               2-cd2
               3-ed1
               4-cd3
               ...    
    2- ...

I tried 'projekt' instead of 'projekte'. But then only the first image in 3-testprojekt is displayed.
I’ve played arround with ->invisible(). But then no projects are displayed.

So ->children->children() is the only thing that works.

Instead of ->children()->children() you can use grandChildren().

Okay. Thanks for this hint.

Is there a “right or wrong” with ->children()->children() and grandChildren()?
And why I can’t write ‘projekt’ instead of ‘projekte’?

The page() helper needs the full path to the page, so

page('projekte/projekt')->children();

would also work.

It’s no problem to use ->children()->children(), but grandChildren() is shorter …

1 Like