October CMS And Navigation On Current Page

I am trying to get the basically the active class applied to the current page. As it goes, the builder plugin is setting the URL through:

<a target="_blank" rel="nofollow noreferrer" href="{{ detailsPage|page({ (detailsUrlParameter): attribute(record, detailsKeyColumn) }) }}">

However I am new to October so I am not sure how to reference in comparison to the url set above.

Basically I want this:

{ set UrlParam = detailsPage|page({ (detailsUrlParameter): attribute(record, detailsKeyColumn) } {% if == UrlParam %} class="active" {% endif %}

Any ideas?



One of the best debugging plugins out there for OctoberCMS is this:

That plugin makes connecting your twig templates to your database / php rendering a breeze.

After installing that plugin you can use {{ d(variable) }} instead of {{ dd(variable) }} and get more information on the array nests etc.

So I would do {{ d(UrlParam) }} and {{ d( }} in your twig template. See what the dump has to say about each of those variables. For clarity I do believe you need the % here {**%** set 'variable' **%**}.

I am also not a fan of the builder component and I use the PHP section on the page / partial pages. And establishing a class with the use function and access the data with $this['variable']. Maybe worth looking into here is a quick example:


function onStart() {
    $plugin = Pluggin::all();
    $this['plugin'] = $plugin;