Forum

Thread tagged as: Question, Problem, Configuration

Portfolio With Categories

Is there a way to assign more than one category to an item. For instance say I want a portfolio item to appear in a general unfiltered portfolio and also in another that has combined sections.

For example I have two categories, mini brochures and folders, in one portfolio I would like to have some of the folders display with the mini brochures (but not all). So logic would tell me to add two categories to each folders item the use this on the combo listing page:

<?php perch_content_custom('Portfolio', array(
    'category' => array('portfolio/mini-brochures', 'portfolio/mini-brochures-combo'),
    'category-match' => any,
    'template' => 'portfolio_listing_filtered.html',
    ));
?>

and this in the portfolio item:

<perch:categories id="Portfolio" label="Category" set="portfolio">

But adding two categories to a portfolio item seems to break the listing altogether e.g. nothing displays.

Nigel Coath

Nigel Coath 1 points

  • 6 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Yes, that's what you would do. You need to quote the any in your example above.

I did figure it out, however as the portfolio items in the main gallery are using an isotope filter that draws a class based on the category name it won't work as it ends up adding both as a class name!

Is there any way to add an item to two different sets without the second code showing up on the item page?

Say I have <perch:categories id="Portfolio" label="Category" set="portfolio"> with the catTitle for it in the edit form

and I want to say add <perch:categories id="Portfolio" label="Combo Category" set="filtered">

but not have this show on the html on the item page?

Drew McLellan

Drew McLellan 2638 points
Perch Support

You've used the same ID for both. Is there are reason?

No just my stupidity, I assumed as the region was called Portfolio that creates the items it had to be that.

But anyway how do I add the item to another set/category without having that show on the html on the front end?

Drew McLellan

Drew McLellan 2638 points
Perch Support

You mean having hidden categories?

Add a field to the category template to mark it as hidden (or whatever) and then use <perch:if> to test for that in your template when you output the categories.

No I think you may have misunderstood.

So my gallery item template is based on what is on the detail page so has all the required perch regions in it.

Currently I have the category title in the heading of the page e.g.

<h1><perch:categories id="Portfolio" label="Category" set="portfolio">
<perch:category id="catTitle" /></perch:categories>: <perch:content id="title" type="text" label="Project Title" title="true" /></h1>

When adding an item in admin I get the Category field to choose a category.

Now say I wanted to have a second Category/Set to assign that I could assign, but not have it appear in the front end?

Why? So I can filter by it on another page, because I might want to group the items in a different way.

So say I add:

<perch:categories id="filtered" label="Combo Category" set="filtered">

What do I do to have it appear in admin but not on the front end, but still add the category to the item so that I can filter by it later?

suppress=true?

Drew McLellan

Drew McLellan 2638 points
Perch Support

<perch:categories id="filtered" label="Combo Category" set="filtered"></perch:categories>

should do it. It has no output, so nothing will be output.

Great thanks for that! Spent ages last night trying things that did not work.

One reason why I am on my 9th Perch licence and about to take it to double figures... great support!!