We're working with the php-based CMS Kirby but are having trouble understanding where we can (and can't) use chaining (we're pretty green when it comes to php).
We have a product section like this:
|_Shop
|_Sheets
|_Sheet one
|_Sheet two
|_Bed spreads
|_Bed spread one
|_Bed spread two
And are trying to deliver a list of all the product child pages under each category.
How do we do this?
We keep seeing a lot of "Call to a member function on a non-object" errors which we're assuming has to do with the way we're chaining things - e.g. we've tried many ways of doing this but are currently trying:
$productPages = $pages->findByDirname('sheets, duvet-covers, bed-spreads, pillowcases, table-linen');
But are unsure how to find the children of these pages as adding ->visible()->children()
either to the end of $pages
above or into the foreach loop like this results in errors:
<?php foreach($productPages->visible()->children() as $pageList) : ?>
Also, we can see that the $page variable has the ->visible()->children()
variables so assume we need to hand our $productPages
variable over to the $page
variable so we can use visible()->children()
but are unsure how to construct things sorry.
Any pointers in the right direction would be much appreciated.
Cheers