crazedsanity/fleximenu

PHP 中灵活的菜单构建器(最初为 lavary/fleximenu)

v0.1.0 2017-08-18 14:16 UTC

This package is not auto-updated.

Last update: 2024-09-18 22:01:51 UTC


README

PHP 中灵活的菜单构建器

用法

<?php

$menu = new Fleximenu\Menu;

$menu->add('Home', '');

$about = $menu->add('About', 'about');

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

// we can attach HTML attributes to the hyper-link as well
$about->link->attributes(['class' => 'link-item', 'target' => '_blank']);

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

$t = $about->add('Who we are?', array('url' => 'who-we-are',  'class' => 'navbar-item whoweare'));
$about->add('What we do?', array('url' => 'what-we-do',  'class' => 'navbar-item whatwedo'));


$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->asUl( attribute('class' => 'ausomw-ul') );

//OR

echo $menu->asOl( attribute('class' => 'ausomw-ol') );

// OR

echo $menu->asDiv( attribute('class' => 'ausomw-div') );

?>

如需帮助

请使用 GitHub 问题提交所有问题和疑问,我将尽力帮助您 :)

许可协议

Fleximenu 是在 MIT 许可协议下分发的免费软件