Forum
Displaying categories at runtime in order to use PerchSystem::set_var
I've outputted a list of categories that I'm using as a category filter and I'd like to add a class to the currently selected filter - ideally using perch and not javascript. I stored the query string in a variable using PerchSystem::set_var
(say the query is ?category=e-homes
) and I was planning on doing something clever with that variable and comparing against the catSlug using <perch:if>
to determine whether an active class gets added (whether this will work is currently untested), however I've just discovered that you can only use variables set by PerchSystem
in templates parsed at runtime.
Is there a way that I can output my list of categories at runtime? I've looked in the categories runtime script and can't see something along the lines of perch_categories_custom
.
Has anyone done something similar to what I'm trying to achieve?
Category templates are parsed at runtime, so there should be no issue there.
This is what I'm doing:
..and then my template:
Nevermind Drew - I needed to change <perch:content id="project_category" /> to <perch:category id="project_category" />
Works now ;-)
For anyone wanting to know, this is how my template ended up: