Skip to content

Active class and route with pagination #15

@n-osennij

Description

@n-osennij

I have next menu

<div class="list-group">
    <a href="{{route('products')}}"
       class="list-group-item list-group-item-action {{ active(route('products', ['category' => null])) }}">
        All
    </a>
    @foreach(App\Category::all() as $category)
        <a class="list-group-item list-group-item-action {{ active(route('products', ['category' => $category->slug])) }}"
           href="{{route('products', ['category' => $category->slug])}}"
        >
            {{$category->name}}
        </a>
    @endforeach
</div>

This is a munu of categories. Route is next (Note - In category menu I do not use now label)

Route::get('/products/{category?}/{label?}', 'CatalogController@index')->name('products');

I show products in category with pagination. First page (without ?page= in url) is fine - munu have active class. But if there are isset ?page= in url - no active class in munu. If I add Label to url - no active class too.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions