anetwork/sidenav 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

anetwork/sidenav

Composer 安装命令:

composer require anetwork/sidenav

包简介

README 文档

README

Build Status Latest Stable Version Total Downloads Latest Unstable Version License Scrutinizer Code Quality Code Coverage

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

Menu options

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

anetwork/sidenav 适用场景与选型建议

anetwork/sidenav 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.23k 次下载、GitHub Stars 达 2, 最近一次更新时间为 2016 年 10 月 08 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 anetwork/sidenav 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 anetwork/sidenav 我们能提供哪些服务?
定制开发 / 二次开发

基于 anetwork/sidenav 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 1.23k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 2
  • Forks: 4
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-10-08