Forum

Thread tagged as: Question

Confused with Categories

I'm looking to rework a years-old Perch 1 site, and thinking I could use categories where previously I used some nasty custom queries in order to display user-created pages on some 'static' pages. I'm struggling to work out how best to do this though and could do with some pointers.

It's a tour operators site with pages for various countries. The user can create tours pages that need to be linked to from these country pages.

I've created a category set for countries, with a category for each country. Using this in my tour master-page template I can assign any tour I create to relevant countries. What I can't get my head around is how to then list and link to this newly created page.

By way of specific example:

Category set = 'Countries' Categories in 'Countries' set = 'canada, usa, mexico'

I have static pages, usa.html, canada.html, and mexico.html

I create a tour page called 'Crossing North America' (tours/crossing-north-america.html) and select canada and usa as categories.

How would I best go about listing this tour page on the correct country pages? So, as pseudo code on say, usa.html 'list tour pages where category equals usa'.

Hope this makes sense, and thanks!

Pete Aylward

Pete Aylward 0 points

  • 5 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

You can use the 'category' option to filter a region by category.

perch_content_custom('Tours', [
    'category' => ['countries/usa'],
]);

Cheers Drew,

Your pointer and the 'Portfolio with Categories' video tutorial sorted me out.