Forum
Displaying categories and its items without category.php page
Hello,
I have a list and details page set up like your Portfolio with Categories example. I'm trying to display a list of categories and all the items within that category on one page (so not using a category.php page).
Eg:
Category 1 Title (from the category template)
Category 1 Description (from the category template)
Item A within Category 1
Item B within Category 1
Category 2 Title (from the category template)
Category 2 Description (from the category template)
Item A within Category 2
Item B within Category 2
I'm getting a bit stuck as the only examples I can find are using a category page and calling it from the slug.
This is what I have that I need to put together:
Getting the categories:
<?php perch_categories(); ?>
Getting the Items
<?php
perch_content_create('Products', array(
'template' => 'product-detail.html',
'multiple' => true,
'edit-mode' => 'listdetail',
));
perch_content_custom('Products', array(
'template' => 'product-listing.html',
'category' => perch_get('cat'),
));
?>
You would use an each callback, loop through the categories and then for each one get the items.
This example does it with Collection data but there isn't any difference to any other content https://docs.grabaperch.com/runway/collections/callback-functions-with-each/
I'm using Perch not Runway, can you still filter using each?
Yes each works across the different _custom functions (other than some very old apps)