Forum

Thread tagged as: Question, Problem

Unable to sort categories by field

Hello,

I'm trying order my categories by an additional field but it doesn't seem to be working via the usual 'sort' and 'sort-order' method. Here is the code block that is giving me an issue..

perch_categories([
    'set' => 'fancy-grid',
    'template' => '_grid.html',
    'count' => 6,
    'sort' => 'gridPos',
    'sort-order' => 'ASC',
]);

Once I add the sort and sort-order attributes the region is skipped and the rest of the template renders. I turned on debugging and found this message...

Invalid query: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'gridPos' in 'order clause'

It seems to cause this issue with anything that isn't part of the original category.html template, so catTitle and catSlug work fine. When I created the set, I created and selected a different category template from the default.

I'm on the latest version of Perch (2.7.10). I'm guessing this is my fault some how but I'm wondering if there is a way around it?

Thank you kindly.

Mark Greenwood

Mark Greenwood 0 points

  • 6 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

That certainly sounds like a bug. I've logged it and will see what we can do.

Ah, that's good to know, thanks Drew. I'll hold off on the 'fancy-grid' for now. If you need any more details from me, just give us a shout, I've got e-mail notifications on this thread.

Cheers, Mark