How to make buttons that stay active/clicked (VoltCMS)

HI!
With VoltCMS loading I’m thinking I’d make some sort of filter to filter by Category.
I have two main categories, and I’d like to make it easy to choose which category to show, and to reset it.

Of course, if I just make links to /blog/?category="category", but then it’s not as visible which category you are filtering by. It would be better if I could make regular buttons or radio buttons where one is active (Category1, Category2 or All/No filter).
Maybe this is just trivial. I know how to make forms and buttons, but since the response reloads the blog page with the option chosen, I’m unsure on how to make the button selected/active … :nerd_face:

Or maybe I should do it some other way … :thinking:
I can probably use some variable …

I think I found a way, experts please correct me if this is potentially bad somehow … :grimacing:

I added the links as buttons using a Code Widget Content module, one for each button something like:

<a href="/blog/category/foo" class="flips-custom-btn<?php
if ($_GET['category'] === "foo") {
    echo ' active';
}  ?>
">Show Foo</a>

(And for the clear filter/show all button the if checks that category from URL is not set:
if (!isset($_GET['category'])) { … )

1 Like