PHP code example of anetwork / sidenav

1. Go to this page and download the library: Download anetwork/sidenav library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

anetwork / sidenav example snippets


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 ...
     *
     */
    
});

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;
     
     });
    
});

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;
});

SideNav::group('user',function(){

    // Registering Items

});

SideNav::render();

SideNav::render('name_of_your_group');