Search code examples
laraveloctobercms

OctoberCms Blog plugin categories into 'activeMenuItem' function?


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 %}

Solution

  • function onEnd() {
        $this['activeMenuItem'] = $this->post->categories[0]->slug;
    }