Forum
Looping through all categories, displaying all items within each category
Working on a FAQ page where questions are categorised, and each category is displayed within an accordion panel. The number of categories is unknown and will be managed from the CMS.
Here's the HTML I'm trying to output:
<div id="horizontalTab">
<ul class="resp-tabs-list">
<li>**Category 1**</li>
<li>**Category 2**</li>
<li>**Category 3**</li>
<li>**(listing all categories)**</li>
</ul><!-- /.resp-tabs-list -->
<div class="resp-tabs-container">
<div class="category-list">
<figure>Item 1 (from category 1)</figure>
<figure>Item 2 (from category 1)</figure>
<figure>Item 3 (from category 1)</figure>
<figure>Item 4 (from category 1)</figure>
<figure>Item 5 (from category 1)</figure>
<figure>Item 6 (from category 1)</figure>
<figure>listing all items within the first category</figure>
</div><!-- /.category-list -->
<div class="category-list">
<figure>Item 1 (from category 2)</figure>
<figure>Item 2 (from category 2)</figure>
<figure>Item 3 (from category 2)</figure>
<figure>listing all items within the second category</figure>
</div><!-- /.category-list -->
<div class="category-list">
<figure>Item 1 (from category 3)</figure>
<figure>Item 2 (from category 3)</figure>
<figure>Item 3 (from category 3)</figure>
<figure>Item 4 (from category 3)</figure>
<figure>listing all items within the third category</figure>
</div><!-- /.category-list -->
</div><!-- /.resp-tabs-container -->
</div><!-- /#horizontalTab -->
1) Listing all categories in "resp-tabs-list" ul is straightforward:
<?php
// list all categories
perch_categories(array('set'=>'faq','template'=>'category.tabs.list.html'));
?>
2) resp-tabs-container: this is where I'd like to loop through all categories, each time listing all corresponding items.
How would you proceed? Would you recommend using collections?
Thank you
menu
submenu
Had to create the following routes with runway
Also try this
Thank you very much Lexi for putting me on the right track!
I've ended up using this:
Simpler than expected.