anetwork / sidenav
Installs: 1 229
Dependents: 0
Suggesters: 0
Security: 0
Stars: 3
Watchers: 3
Forks: 4
Open Issues: 0
Requires
- php: >=5.5
Requires (Dev)
- phpunit/phpunit: ^5.6
This package is not auto-updated.
Last update: 2024-11-09 20:07:06 UTC
README
Anetwork SideNav
SideNav is a PHP package which helps you generate powerful sidebar navigation.
Features
- SubMenu : Define your submenu to item
- Grouping : Define your items in groups
- Cheking : Define dynamic menues and submenues with if statement support
Introduction
- A php component that makes it easier to build vertical nav menus
- The sidenav package can manage your sidebar navigations items on your project
- you can install this package with composer and config your sidebar navigations items
Requirement
- php 5.5 >=
- HHVM
Install with composer
You can install this package throw the Composer by running:
composer require anetwork/sidenav
Register a new item
- you should use the register method of sidenav object
- the method wants 2 arguments
- the first one should be a string of your item name
- the second one must be a function literal to use Menu Object for define all of menu options
SideNav::register('item_name',function($menu){ $menu->link('the_item_url'); $menu->title('the title'); $menu->className('class-name'); // Item css class attribute $menu->icon('fa fa-example'); // use on font-awesome icon // Register submenu to item $menu->sub('sub_item_name',function ($menu){ $menu->link('the_item_url'); $menu->title('the submenu title'); $menu->icon('fa fa-example'); $menu->className('submenu-class-name'); }); /** * * Register another one ... * */ });
Register submenu with Check Status
If you want register a submenu in item with checkStatus, you should use subWithCheck method of Menu Object
- the method , accepts 3 arguments
- first one must be a string of your item name
- second one must be function literal to use Menu Object for define all of menu options
- third one must be a function literal of your check state , return of function must be true or false
SideNav::register('item_name',function($menu){ /** * * Items options ... * */ $menu->subWithCheck('sub_item_name',function($menu){ /** * * Item options ... * */ },functiion(){ // checking area // you can define the if statement here to return boolean | true or false // :: Example if($_SESSION['user_id'] == 2){ return true; } return false; }); });
Register With Check Status
If you want register a item with checkStatus, you should use registerWithCheck method of SideNav Object
- the method , accepts 3 arguments
- first one must be a string of your item name
- second one must be function literal to use Menu Object for define all of menu options
- third one must be a function literal of your check state , return of function mustb be true or false
SideNav::registerWithCheck('item_name',function($menu){ $menu->link('the_item_url'); $menu->title('the title'); $menu->className('class-name'); $menu->icon('fa fa-example'); },function(){ // checking area // you can define the if statement here to return boolean | true or false // :: Example if($_SESSION['user_id'] == 2){ return true; } return false; });
Group
- You can make a group menu with SideNav::group method
SideNav::group('user',function(){ // Registering Items });
Render
- You can use the render method of SideNav object to return your menu array
SideNav::render();
- if you want to render your group , just call your group name in argument
SideNav::render('name_of_your_group');