symplely/menu 问题修复 & 功能扩展

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

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

symplely/menu

Composer 安装命令:

composer require symplely/menu

包简介

A simple menu builder in PHP

README 文档

README

Build StatusBuild statuscodecovCodacy BadgeMaintainability

A simple menu builder in PHP

Installation

To install this library make sure you have composer installed, then run following command:

composer require symplely/menu

Usage

A menu can be instantiated and items can be added fluently with the add method, which requires a url and a string of text as parameters.

<?php
require_once 'vendor/autoload.php';

$menu = new Async\Menu\Menu;

// The main menu
$menu->add('Home', '');

// Creates a sub menu
$about = $menu->add('About', 'about');

// Creates a another sub menu from the sub menu, passing url and other attributes in key = value pair.
$support = $about->add('Who we are?', ['url' => 'who-we-are', 'class' => 'navbar-item who']);

// Add items to sub menu, passing url and other attributes in key = value pair.
$about->add('What we do?', ['url' => 'what-we-do', 'class' => 'navbar-item what']);

// Item has sub items we append a caret icon to the hyperlink text
$about->append(' <span class="caret"></span>');

// Or just the preset, $default = 'caret'
$about->caret($default);

// Attach HTML attributes to the hyper-link as a key = value array
$about->attributes(['class' => 'link-item', 'target' => '_blank']);

// Or Separately
$about->attributes('data-model', 'nice');

// Or the shorter
$about->addClass('link-item');
$about->addTarget('_blank');

// Add more items to the main menu
$menu->add('Portfolio', 'portfolio');
$menu->add('Contact', 'contact');

// we're only going to hide items with `display` set to **false**
$menu->filter( function($item) {
    if ($item->meta('display') === false) {
        return false;
    }
    return true;
});

// Now we can render the menu as various HTML entities:
echo $menu->renderUnordered(['class' => 'some-ul']);

// OR
echo $menu->renderOrdered(['class' => 'some-ol']);

// OR
echo $menu->renderDiv(['class' => 'some-div']);

// For bootstrap users
echo bootstrap_menu($menu);

Let's get things started by building a simple menu with two links. All of the following examples are using classes from the Async\Menu namespace.

<ul>
    <li><a href="/">Home</a></li>
    <li><a href="/about">About</a></li>
</ul>
$menu = new Link;
$menu->add('Home', '/')
$menu->add('About', '/about'));

When we render or echo the menu, it will output our intended html string.

// Via the `render` method:
echo $menu->render();

// Or just through `__toString`:
echo $menu;
<ul>
    <li><a href="/">Home</a></li>
    <li><a href="/about">About</a></li>
</ul>

The functional approach

$menuInstance = \create_menu($url, $urlName, $iconImage, $iconType, $anyPreviousMenuInstance);
$subMenu = \create_menuSub($menuInstance, $url, $urlName, $iconImage, $iconType);
\create_menuItem($subMenu, $url, $urlName, $iconImage, $iconType);

print $menuInstance->render());
// Or
print \bootstrap_menu($menuInstance);

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 10
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-11-22

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固