Closed Michael-Reich closed 3 years ago
It might be easier for you to use a custom variable
function onStart()
{
$this['activeMenu'] = 'my-category';
}
==
<a class="nav-link {% if activeMenu == 'my-category' %}active{% endif %}" href="{{ 'category'|page({ slug: 'cinema-4d' }) }}">My Category</a>
But how I can make this with a :slug Site? The Plugin generates the category pages.
Item can belong to many categories, to use the first one, something like
function onStart()
{
$this['activeMenu'] = $this->showcaseItem &&
$this->showcaseItem->item &&
$this->showcaseItem->item->categories->count()
? $this->showcaseItem->item->categories->first()->slug
: 'unknown-category';
}
Is it possible to get the page.id from the catgory slug? Like in the href option? But I want it in the if statement.
<a class="nav-link {% if this.page.id == 'my-category' %}active{% endif %}" href="{{ 'category'|page({ slug: 'cinema-4d' }) }}">My Category</a>