Tagged: laravel 5 navigation menu

Laravel Dynamic active menu Example Tutorial 0

Laravel Dynamic active menu Example Tutorial

Today, We want to share with you Laravel Dynamic active menu Example Tutorial.In this post we will show you laravel active menu item, hear for laravel request is and laravel request::is we will give you demo and example for implement.In this post, we will learn about laravel 5.7 navigation menu with an example.

Laravel Dynamic active menu Example Tutorial

There are the Following The simple About Laravel Dynamic active menu Example Tutorial Full Information With Example and source code.

As I will cover this Post with live Working example to develop laravel 5.7 active class with active states laravel, so the some major files and Directory structures for this example is following below.

LARAVEL ADDING CLASS .ACTIVE TO CURRENT LINK

step 1: Create a helpers.php

function isActive($path)
{
    return Request::is($path . '*') ? ' active' :  '';
}

step 2: Add in composer.json files

"autoload": {
        "classmap": [
            "database"
        ],
        "files": [
            "app/helpers.php"
        ],
        "psr-4": {
            "App\": "app/"
        }
    },

step 3: How to use it:

<ul class="nav navbar-nav">
     
    <li class="{{ isActive('products') }}">
       <a href="{{ url('products') }}"><i class="fa fa-fw fa-user"></i> Products</a>
    </li>
 
 </ul>

Laravel 5.7 active menu item using request

<li class="{{ Request::is('status*') ? 'active' : '' }}">
    <a href="{!! route('status.index') !!}"><span>Status</span></a>
</li>
<li class="{{ Request::is('users*') ? 'active' : '' }}">
    <a href="{!! route('users.index') !!}"><span>Users</span></a>
</li>
<li class="{{ Request::is('roles*') ? 'active' : '' }}">
    <a href="{!! route('roles.index') !!}"><span>Roles</span></a>
</li>

Highlight Active Nav Links using Laravel

We can use ternary operator with 3 Examples. For example, We can check dynamic URI for the current ul > li route:

using ternary operator

<li{{ request()->is('product-types') ? ' class="active"' : '' }}>

using * as wildcard:

<li{{ request()->is('product-type-number-*') ? ' class="active"' : '' }}>

using check route name

<li{{ request()->route()->getName() === 'ProductType.index' ? ' class="active"' : '' }}>

Angular 6 CRUD Operations Application Tutorials

Read :

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about Laravel Dynamic active menu Example Tutorial.
I would like to have feedback on my Pakainfo.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Handling Active Navigation Menu in Laravel Example 0

Handling Active Navigation Menu in Laravel Example

Today, We want to share with you Handling Active Navigation Menu in Laravel Example.In this post we will show you Active menu item with multi level submenus in Laravel, hear for Laravel Add active class to Nav Menu System we will give you demo and example for implement.In this post, we will learn about laravel 5 navigation menu, laravel active route with an example.

Handling Active Navigation Menu in Laravel Example

There are the Following The simple About Handling Active Navigation Menu in Laravel Example Full Information With Example and source code.

As I will cover this Post with live Working example to develop Handling active menu item in Laravel 5, so the laravel blade directive render current menu item active for this example is following below.

Example 1: laravel 5 active menu product

<li class="{{ Request::is('examples*') ? 'active' : '' }}">
    <a href="{!! route('examples.index') !!}"><span>Examples</span></a>
</li>
<li class="{{ Request::is('categories*') ? 'active' : '' }}">
    <a href="{!! route('categories.index') !!}"><span>Categories</span></a>
</li>
<li class="{{ Request::is('members*') ? 'active' : '' }}">
    <a href="{!! route('members.index') !!}"><span>Members</span></a>
</li>

Example 2: laravel 5.5 active menu product

helper file

function set_active( $route ) {
    if( is_array( $route ) ){
        return in_array(Request::path(), $route) ? 'active' : '';
    }
    return Request::path() == $route ? 'active' : '';
}

Usage

<li class = "{{ set_active('member/users') }}">
    <a href="{{ url('/member/users/') }}">Users</a>
</li>

Multi-level(Handling active menu item in Laravel 5)

<li class="{{ set_active(['member/products', Request::is('member/auction/*'), 'member/allinfo']) }}">
    <ul>
        <li class = "{{ set_active('member/product') }}">
            <a href="{{ url('/member/product') }}">All</a>
        </li>
        <li class = "{{ set_active('member/product/create') }}">
            <a href="{{ URL::to('/member/product/create') }}">Add New</a>
        </li>
        <li class = "{{ set_active('member/allinfo') }}">
            <a href="{{ URL::to('/member/allinfo') }}">AllInfo</a>
        </li>
    </ul>
</li>

Using Request::url()

// For https://pakainfo.com/articles
<li class="{{ Request::url()== url('/articles') ? 'active' : '' }}">
     <a href="{{ url('articles') }}">articles</a>
</li>
// For articles inner link like articles/post
<li class="{{ Request::segment(2) == 'post' ? 'active' : '' }}">
     <a href="{{ url('articles/post') }}">Post</a>
</li>

Angular 6 CRUD Operations Application Tutorials

Read :

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about Handling Active Navigation Menu in Laravel Example.
I would like to have feedback on my Pakainfo.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

PHP Laravel 5.6 Dynamically Add Active class 0

PHP Laravel 5.6 Dynamically Add Active class to The Navigation Menu

Today, We want to share with you PHP Laravel 5.6 Dynamically Add Active class to The Navigation Menu.In this post we will show you php – Setting Bootstrap navbar active class in Laravel 5.6, hear for Add active class to old dynamic nav using 5.6 and bootstrap 4 we will give you demo and example for implement.In this post, we will learn about Adding class .active to current link in Laravel 5.6 with an example.

PHP Laravel 5.6 Dynamically Add Active class to The Navigation Menu

There are the Following The simple About PHP Laravel 5.6 Dynamically Add Active class to The Navigation Menu Full Information With Example and source code.

As I will cover this Post with live Working example to develop How add active state to the navigation menu with Laravel 5.6, so the some major files and Directory structures for this example is following below.

  • Laravel 5.6 active menu
  • Laravel 5 active menu

Laravel 5.6 active menu item using request

check route name

<li{{ request()->route()->getName() === 'productType.index' ? ' class="active"' : '' }}>

use * as wildcard

<li{{ request()->is('product-type-number-*') ? ' class="active"' : '' }}>

use ternary operator

<li{{ request()->is('products-types') ? ' class="active"' : '' }}>

Laravel 5.5 active menu item using request

<li class="{{ Request::is('products*') ? 'active' : '' }}">
    <a href="{!! route('products.index') !!}"><span>Products</span></a>
</li>

<li class="{{ Request::is('category*') ? 'active' : '' }}">
    <a href="{!! route('category.index') !!}"><span>Category</span></a>
</li>

<li class="{{ Request::is('status*') ? 'active' : '' }}">
    <a href="{!! route('status.index') !!}"><span>Status</span></a>
</li>

Angular 6 CRUD Operations Application Tutorials

Read :

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about PHP Laravel 5.6 Dynamically Add Active class to The Navigation Menu.
I would like to have feedback on my Pakainfo.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.