Forum
Filtering articles collection list by category
I'm trying to list all the articles assigned to a specific category using the following but getting no output:
perch_collection('Articles', [
'template' =>'article-category-list.html',
'category' => 'categories/overview/good-posture/'
]);
'categories' is the set, 'overview' is a parent category and 'good-posture' a sub-category. If I remove 'category' => 'categories/overview/good-posture/' from the array, all the articles are output regardless of what category they're assigned to, as expected. Any idea why passing the category in the array doesn't work?
Does removing the trailing slash have any impact?
No, still nothing without the trailing slash :( Also tried removing 'categories' with & without the slash, 'good-posture' on its own, etc. Here's the template if that's any help:
'cat_slug' is passed from the URL & set as a system variable prior to calling the template.
If you turn on debug, what does it output for the page?
All working now - changing something in one of the templates must have caused the issue which was fixed by re-saving all the articles.
On that note, are there any plans for a 'Republish' function / button for collections that would save one having to re-save all articles 1 by 1?
Thanks again for the responses & sorry for the recent forum bombardment!
What's the scenario whereby you'd need to save the items one by one?
Not entirely sure but I suspect that changes to one the template files caused the filtering by category to stop working - maybe the content in one of the entries didn't match the ids in the template file? Can't say for sure but it works now & hopefully won't happen again!
Ok, great.