2017 © Pedro Peláez
 

library tabmenu

HTML menu creator for Blade

image

dnabeast/tabmenu

HTML menu creator for Blade

  • Wednesday, July 27, 2016
  • by dnabeast
  • Repository
  • 1 Watchers
  • 1 Stars
  • 29 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

HTML menu creation for Laravel Blade

This allows you to define your HTML menu system using easy to read syntax in a blade file., (*1)

It allows the menu urls to change if it's called from an admin directory., (*2)

Installing

Add the dependency to your project:, (*3)

composer require DNABeast/tabmenu

Publish the config file

php artisan vendor:publish

Laravel 5.5:

The ServiceProvider is automatically discovered., (*4)

Laravel 5.2:

Add to your app.php config., (*5)

DNABeast\TabMenu\TabMenuServiceProvider::class,

You may need to clear the view cache, (*6)

php artisan view:clear

Usage

In your blade file enter the custom @menu directive, and the @endmenu directive. Enter your menu as a text list. You can indent if you wish., (*7)

@menu
[tab][tab]Menu 1
[tab][tab]Menu 2
[tab][tab]Menu 3
@endmenu

outputs, (*8)

<ul>
    <li><a href="/menu-1">Menu 1</a></li>
    <li><a href="/menu-2">Menu 2</a></li>
    <li><a href="/menu-3">Menu 3</a></li>
</ul>

Add a tab and the menu item will become a sub-menu., (*9)

@menu
[tab][tab]Menu 1
[tab][tab][tab]Menu 1a
[tab][tab][tab][tab]Menu 1ax
[tab][tab]Menu 2
@endmenu

creates, (*10)

<ul>
    <li><a href="/menu-1">Menu 1</a><ul>
        <li><a href="/menu-1a">Menu 1a</a><ul>
            <li><a href="/menu-1ax">Menu 1ax</a></li></ul>
        </li></ul>
    </li>
    <li><a href="/menu-2">Menu 2</a></li>
</ul>

Set URLs

Put a comma and set the url when it's different to the menu name, (*11)

@menu
Menu, /menu-one-location
Menu 2
@endmenu

becomes, (*12)

<ul>
    <li><a href="/menu-one-location">Menu</a></li>
    <li><a href="/menu-2">Menu 2</a></li>
</ul>

Set a Class

If your menu item requires a class name just add it after a second comma, (*13)

@menu
Menu Item, /menu-item, action
@endmenu

becomes, (*14)

<ul>
    <li><a href="/menu-item" class="action">Menu Item</a></li>
</ul>

Unwrap the primary ul tag

If you need to add manual menu items it's useful to be able to remove the wrapping <ul> tag., (*15)

Publish the config file, (*16)

php artisan vendor:publish

and change the nowrap flag to true., (*17)

@menu
Menu Item, /menu-item, action
@endmenu

becomes, (*18)

    <li><a href="/menu-item" class="action">Menu Item</a></li>

Change the tabs to spaces

I get it. You prefer pragmatism over semantics. You can change the tab to 2 spaces or 4 spaces if you like., (*19)

In the published config file type whatever your preferred indentation is., (*20)

'indent' => '----'

In the published config file enter the name of your admin folder., (*21)

'prefix' => 'dashboard'

The Versions

27/07 2016

dev-master

9999999-dev

HTML menu creator for Blade

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dan Beeston

laravel blade menu