responsiv / showcase-plugin

[PREMIUM] Create and manage portfolios for showcasing products or services.
http://octobercms.com/plugin/responsiv-showcase
0 stars 0 forks source link

If current Slug? #2

Closed Michael-Reich closed 3 years ago

Michael-Reich commented 8 years ago

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>

daftspunk commented 8 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>
Michael-Reich commented 8 years ago

But how I can make this with a :slug Site? The Plugin generates the category pages.

daftspunk commented 8 years ago

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';
}