SideNav is a PHP package which helps you generate powerful sidebar navigation.
- SubMenu : Define your submenu to item
- Grouping : Define your items in groups
- Cheking : Define dynamic menues and submenues with if statement support
- 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
- php 5.5 >=
- HHVM
You can install this package throw the Composer by running:
composer require anetwork/sidenav
- 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 ...
*
*/
});
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;
});
});
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;
});
- You can make a group menu with SideNav::group method
SideNav::group('user',function(){
// Registering Items
});
- 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');
Method | status | Parameter | Type of parameter |
---|---|---|---|
->icon() |
required | Define icon class | String |
->link() |
required | Set link of item | String |
->regex() |
optional | Set the regex of item link | array |
->className() |
optional | The class of item | String |
->newTab() |
optional | newTab link target | Boolean : defalt => false |
->title() |
required | The title of item | String |
->isNew() |
optional | Define the item is new | Boolean : default => false |
->selected() |
optional | item selected status | Boolean : default => false |
->openChildOnClick() |
optional | the sub menu status | Boolean : default => true |