We are transitioning over to a new forum platform. Please post new issues there. Existing threads will be dealt with here unless you choose to move them over. Visit the new forum
Forum
Categories and Perch Runway
Hi Guys,
I have never really used categories much and so I am a little stuck/lost. Wondered if you can perhaps give me some direction.
I have created a list and details page and I want to be able to filter the stories based on the categories. So if you click one of the categories in then it would show you a list of all stories for that category.
I have setup my cats in the backend and I have my list and details page working. But not I am trying to filter I am stumped. I am not sure what I need to setup in order to achieve this? I assume I would do the filtering with some if statements on the same stories.php template where my list/details are shown, but as this is runway I am also unsure about what routes to add etc?
Thanks in advance
Terry
Want to reply to this thread?
Login with Perch
What do you want the URLs to be?
For example;
stories/age-group/0-5/
stories/age-group/6-10/
stories/diagnosis/acute-lymphoblastic-leukaemia/
stories/diagnosis/acute-myeloid-leukaemia/
Are
age-group
anddiagnosis
your category sets?Yes they are
What does your detail page URL look like?
Currently looks like - http://supershoes.loc/stories/2015-08-10-nathan/
Ok, so I think you need routes like
Then logic like:
Thanks for this Drew. I have it all working now as I would like.
However, I have one further question.
I am doing a check on the details page if it exists and throwing a 404 error if not with this code.
This works fine. But how can i do the same for the Categories?
For example if I try any URL like;
stories/diagnosis/acute-lymphoblastic-leukaemiasssssss/ or even stories/test/testing
then I get the page back but without any content. Ideally I would like to 404 any incorrect category URLS.
Thanks, Terry
You can use
perch_category()
to test if the category exists.