I watched Bastiam video on YouTube “How to build a website from scratch part 2”. So I saw how he used toggle to display projects on the frontend. I am trying to imitate actually what he did but for some reason it will not display on the frontend. Can someone tell me what I am doing wrong.
Thank you,
<?php snippet('featured', [
'featured' => page('furniture')
->children()
->listed()
->filterBy('featured', true)
]) ?>
<?php foreach ($featured as $product): ?>
<div class="col-lg-6">
<figure class="featured_products">
<?= $product->image()->crop(570,408)?>
</figure>
</div>
<?php endforeach ?>
Is that code in the same file?
The second part is supposed to be in the snippet file /site/snippets/featured.php
, which you call in the first part of your code block!
If that’s the case, then
page('furniture')
->children()
->listed()
->filterBy('featured', true)
])
probably doesn’t return anything… Do you have featured pages as children of the furniture
page?
The featured is the snippet.
The foreach is inside the snippet.
Again:
The children of the /furniture
page are /homeoffice
and pages on the same level…
That’s what I expected and said above, you are trying to get the wrong level of subpages again. The Austin Coffee Table is not a child of the furniture page, but a grandchild.
Please keep in mind that children
are only the direct subfolders of a given page, not the nested ones. This is important, because you continue having the same sort of problem in many of your questions.
Thank you. I will keep that in mind.