Forum

Thread tagged as: Problem

Issue with category filtering

Hi there,

I ran into a weird issue related to category filtering when two categories share the same prefix.

I have a category set which holds three categories: violon, violoncelle, alto. I assign these categories to a multiple-item regions and I filter the region based on a category like so:

perch_content_custom('Bows', array(
       'template' => 'instruments/instruments_listing.html',
       'category' => 'type/violon'
));

This actually outputs the content from violon as well as violoncelle. If I change the violon category name to a different name but keep 'category' => array('type/violon') for the filtering, it will still output the content from violoncelle. Now, if I use violoncelle category for the filtering, violon items won't be output.

Here's the debug output in case that helps:

Debug Message
SELECT regionKey, regionHTML FROM perch2_content_regions WHERE regionPage='/bows.php' OR regionPage='*' ORDER BY regionPage DESC
SELECT regionID, regionTemplate, regionPage, regionRev AS rev FROM perch2_content_regions WHERE regionKey='Bows' AND (regionPage='/bows.php' OR regionPage='*')
SELECT idx.itemID FROM perch2_content_index idx JOIN perch2_content_items c ON idx.itemID=c.itemID AND idx.itemRev=c.itemRev AND idx.regionID=c.regionID WHERE ((idx.regionID=7 AND idx.itemRev=24)) AND ((idx.indexKey='_category' AND idx.indexValue LIKE 'type/violon%'))
SELECT * FROM ( SELECT idx.itemID, c.regionID, idx.pageID, c.itemJSON, idx2.indexValue as sortval FROM perch2_content_index idx JOIN perch2_content_items c ON idx.itemID=c.itemID AND idx.itemRev=c.itemRev AND idx.regionID=c.regionID JOIN perch2_content_index idx2 ON idx.itemID=idx2.itemID AND idx.itemRev=idx2.itemRev AND idx2.indexKey='_order' WHERE ((idx.regionID=7 AND idx.itemRev=24)) AND idx.itemID IN ('9') AND idx.itemID=idx2.itemID AND idx.itemRev=idx2.itemRev ) as tbl GROUP BY itemID ORDER BY sortval ASC

Cheers,

Robin Pick

Robin Pick 5 points

  • 6 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Try:

 'category' => 'type/violon/'

It works, thanks!