Forum

Thread tagged as: Question

List Pages According to Category

I'm struggling to work out the best way to do this…

My client has 12 services, each of which has a page that is created using a master page template. Those services fit into 3 different categories - a service could appear in all 3 categories, 2 or just one. The 3 categories form part of the navigation and each one needs it's own page that lists out the appropriate pages within it.

I'm really struggling to see the best way to do this and I get the feeling it may be beyond my abilities.

I get the feeling it's one for categories (I may be completely wrong) but I can't see how I would assign a created page to a category.

Thanks for any pointers

David Ellis

David Ellis 1 points

  • 6 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Do the pages have content on them that would serve as a descriptor for the page?

Hi Dave

This solution might help. It was something Drew helped me with last month. It uses collections (Perch Runway) and categories.

I had 50 projects split across 12 categories. Some projects appeared in multiple categories. I had a home page that listed all 12 categories and each category had it's own page.

Maybe you could adapt this to suit your needs?

Hi Drew, yes they do.

Stephen - thanks I'll take a look at that.

Did you have any further thoughts on this one Drew?

Drew McLellan

Drew McLellan 2638 points
Perch Support

Sorry, I thought you were doing something Stephen suggested.

Use perch_content_custom() to output the list using the descriptor content from the pages.

Hi Drew,

To be honest with Stephen mentioning Runway I wasn't sure whether his solution was possible. I'll have a play with perch_content_custom and see where I can get

Thanks

I made some headway into this one by using a pretty simple implementation of perch_custom_content coupled with my own custom category checkboxes for created pages.

                perch_content_custom('Service Title', array(
                    'page'=>'/*',
                    'filter'=>'residential',
                    'match'=>'eq',
                    'value'=>on,
                    'template'=>'_service_list.html'
                )); 
            ?>

In the service list template I'm able to pull the title through easily enough but not sure how to get the relevant link for the created/listed page.

Any pointers would be more than welcome!

Drew McLellan

Drew McLellan 2638 points
Perch Support

What's this line doing?

'value'=>on,

That should at least be

'value'=>'on',

I can change that but the filtering is working (or seems to be), it's getting something to use for a link/path on that listing page that I'm struggling with at the moment

Drew McLellan

Drew McLellan 2638 points
Perch Support

Does the _page field not return what you need?

Not quite sure how to use that - how would I use that in my template?

Drew McLellan

Drew McLellan 2638 points
Perch Support

<perch:content id="_page" />

Thanks Drew, brilliant! Apologies, I know it must be like talking to an idiot sometimes - that's just helped me out so much!