This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.
Username123
How to add Blog "category.slug" to "activeMenuItem"?
function onInit() {$this['activeMenuItem'] = ???;}
Show category.slug in post:
{% for category in post.categories %} {{ category.slug }} {% endfor %}
or
{{ post.categories[0].slug }}
daftspunky
Hey, try this:
function onInit() {
$this['activeMenuItem'] = $this->post->categories[0]->slug ?? null;
}
Username123
daftspunk said:
Hey, try this:
function onInit() { $this['activeMenuItem'] = $this->post->categories[0]->slug ?? null; }
Works with function onEnd()
And can be removed ?? null
Thank you very much!!!
1-4 of 4