Forum
Display all categories with list/detail items
I'm trying to create a category listing with Case Study list/detail items like this:
Category 1
- case study 1
- case study 2
... etc
Category 2
- case study 3
- case study 4
... etc
so that I loop through all available categories that have list/detail items
So far, I can display a single category and its associated case studies as follows:
perch_categories(array(
'set'=>'Case Studies',
'filter'=> 'catTitle',
'match' => 'eq',
'value' => 'categoryname'
));
perch_content_custom('Case Studies', array(
'template' => 'casestudy_category_listing.html',
'category' => 'case-studies/categoryname'
));
but I'm struggling with how to display all categories like this. I could repeat this multiple times but I'd like to loop through this (I think). Can you point me towards the best way of doing this. Thank you.
Grab the
perch_categories()
call into an array usingskip-template
Loop through that array calling
perch_content_custom()
using the value from the array for the category to filter byI'm OK with step 1 but step 2 is a struggle. I can see the array data on the page using print_r but that's as far as I have got.
What does the
print_r
display?As follows:
OK! Thank you.
I am wanting to do pretty much the same thing, but as follows:
What would be the full code needed to produce this all on one page?
I have found an excellent walkthrough doing just this by Jannis on this thread: https://forum.grabaperch.com/forum/07-12-2015-how-to-single-list-of-employees-sorted-by-department-as-categories-with-multiple-categories-per-employee-possible - thanks Jannis!