Laravel - active menu

Asked

Viewed 85 times

0

I am trying for the first time to develop a test website using Laravel and am following a video tutorial on youtube. Everything is going relatively well, but I have a little question that needed your help.

I have a menu with 6 buttons:

li class="principal {{ Request::is('pt/sport/homepage') ? "active" : "" }}"><a href="#">HOMEPAGE</a></li

li class="principal {{ Request::is('pt/sport/quem-somos') ? "active" : "" }}"><a href="#">QUEM SOMOS</a></li

li class="principal {{ Request::is('pt/sport/projetos', 'pt/sport/projetos/$projetoSlug') ? "active" : "" }}"><a href="#">PROJETOS</a></li

li class="principal {{ Request::is('pt/sport/produtos') ? "active" : "" }}"><a href="#">PRODUTOS</a></li

li class="principal {{ Request::is('pt/sport/metodologia') ? "active" : "" }}"><a href="#">METODOLOGIA</a></li

li class="principal {{ Request::is('pt/sport/contatos') ? "active" : "" }}"><a href="#">CONTATOS</a></li

The active state is working perfectly, but on the "Projects" and "Products" pages there will be a grid of photos, which in turn when clicking on one of the photos will go to an individual presentation page of the project or product. Until everything is ok.

My question is this: When I press Projects, my photo grid appears and the button remains active, but after clicking on the photo to open the project individually (who has a photo gallery) the projects button is no longer active.

How do I keep the "Projects" button active?

  • Just as an aside, the html that placed in the question was incomplete in the tags

1 answer

0

To achieve the effect of active class I use the following, it is a bit laborious, but as I use the NAV and then use @extends('Nav') and other @Section.

<li class="{{ request()->is('/') ? 'active' : '' }}"><a href="{{asset('/')}}"><i class="icon-dashboard"></i><span>Página Inicial</span> </a> </li>
            <li class="{{ request()->is('atendimentos') ? 'active' : '' }} {{ request()->is('atendimentos/create') ? 'active' : '' }} {{ request()->is('atendimentos/*/edit') ? 'active' : '' }}"><a href="{{asset('atendimentos')}}"><i class="icon-list-alt"></i><span>Atendimentos</span> </a> </li>
            <li class="{{ request()->is('pessoas') ? 'active' : '' }} {{ request()->is('pessoas/create') ? 'active' : '' }} {{ request()->is('pessoas/*/edit') ? 'active' : '' }}"><a href="{{asset('pessoas')}}"><i class="icon-group"></i><span>Pessoas</span> </a></li>
            <li class="{{ request()->is('financeiro') ? 'active' : '' }} {{ request()->is('financeiro/create') ? 'active' : '' }} {{ request()->is('financeiro/*/edit') ? 'active' : '' }}"><a href="{{asset('financeiro')}}"><i class="icon-money"></i><span>Financeiro</span> </a></li>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.