Ad

OctoberCms Blog Plugin Categories Into 'activeMenuItem' Function?

- 1 answer

Show "slug" category in Post:

{{ post.categories[0].slug }}

But, how to add this "slug" to 'activeMenuItem'?

function onInit()
{
 $this['activeMenuItem'] = ???;
}

Thanks!

UPD, for use here:

{% for item in items %}
<a href="{{ item.url }}">
<span class="{{ item.isActive or item.isChildActive ? ' active' : '' }}">{{ item.title }}</span>
</a>
{% endfor %}
Ad

Answer

function onEnd() {
    $this['activeMenuItem'] = $this->post->categories[0]->slug;
}
Ad
source: stackoverflow.com
Ad