altamash80 / laminas-mvc-bootstrap-menu
此包已被废弃,不再维护。未建议替代包。
此仓库可以基于 ul li 标签生成嵌套 Bootstrap 菜单。以后可能会有更多。谢谢!
v1.2.0
2024-07-11 17:42 UTC
Requires
- php: ^7.3 || ^8.0
- laminas/laminas-eventmanager: ^3.0
- laminas/laminas-loader: ^2.6
- laminas/laminas-modulemanager: ^2.5
- laminas/laminas-mvc: ^3.0
- laminas/laminas-navigation: ^2.10
This package is auto-updated.
Last update: 2024-08-11 18:15:22 UTC
README
此仓库将包含与 laminas-mvc 集成的 Bootstrap 菜单。
先决条件
您需要在 layout.phtml 中包含 bootstrap css 和 js 文件。如果不包含,您仍然可以查看生成的 html。
简介
此包基于您应用程序中提供的配置生成 Bootstrap 菜单。应该与 Laminas-Navigation 兼容。因为此包扩展了 Laminas-Navigation,所以配置应该与 Laminas-Navigation 匹配。这个包是在 Frank Brückner 的帮助下出现的,Frank Brückner 感谢您的帮助。这是我对 Laminas MVC 的第一次贡献。
使用 Composer 安装
composer require altamash80/laminas-mvc-bootstrap-menu
在您的应用程序中注册模块
<?php return [ 'modules' => [ // ... 'Laminas\Navigation', // <-- Add this line if not present 'LRPHPT', // <-- Add this line in your root_path/config/modules.config.php file 'Application', ], ];
菜单容器数组
<?php // Application/config/module.config.php return [ // ... 'navigation' => [ 'default' => [ 'home' => [ 'label' => 'Home', 'route' => 'home', 'resource' => 'home', ], 'category' => [ 'label' => 'Category', 'uri' => '#', 'pages' => [ 'php' => [ 'label' => 'PHP', 'uri' => 'https://php.ac.cn', ], 'laminas' => [ 'label' => 'Laminas', 'uri' => 'https://getlaminas.org/', 'resource' => 'lmcuser', ], 'devider' => [ 'label' => '--devider--', // most important 'uri' => '#', ], 'magento' => [ 'label' => 'Magento', 'uri' => 'https://business.adobe.com/products/magento/magento-commerce.html', ], ], ] ] ], ];
MVC 视图中的使用
<?=$this->navigation('default') ->bootstrapMenu() ->setUlClass('navbar-nav') // Optional setting to use with LmcRbac route guard. ->setAuthorizationService($this->LmcRbacAuthorizationServiceHelper()) ; ?>
HcOffCanvas 菜单
<?php // Application/config/module.config.php use LRPHPT\Navigation\Page as LrphptPage; return [ // ... 'navigation' => [ 'default' => [ 'home' => [ 'label' => 'Home', 'route' => 'home', 'liClass' => 'collections', 'type' => LrphptPage\MvcPage::class, ], 'cryptocurrency' => [ 'label' => 'Cryptocurrency', 'type' => LrphptPage\UriPage::class, 'liClass' => 'cryptocurrency', 'uri' => 'https://www.google.com/search?q=Crypto', 'pages' => [ 'bitcoin' => [ 'label' => 'Bitcoin', 'uri' => 'https://php.ac.cn', 'type' => LrphptPage\UriPage::class, ], 'ethereum' => [ 'label' => 'Ethereum', 'uri' => 'https://getlaminas.org/', 'type' => LrphptPage\UriPage::class, ], ], ], 'devices' => [ 'label' => 'Devices', 'type' => LrphptPage\UriPage::class, 'liClass' => 'devices', 'uri' => '#', 'type' => LrphptPage\UriPage::class, 'pages' => [ 'mobile' => [ 'label' => 'Mobile Phones', 'uri' => '#', 'liClass' => 'mobile', 'type' => LrphptPage\UriPage::class, 'pages' => [ 'mobile1' => [ 'label' => 'Super Smart Phone', 'uri' => '#', 'type' => LrphptPage\UriPage::class, ], 'mobile2' => [ 'label' => 'Thin Magic Mobile', 'uri' => '#', 'type' => LrphptPage\UriPage::class, ], 'mobile3' => [ 'label' => 'Performance Crusher', 'uri' => '#', 'type' => LrphptPage\UriPage::class, ], ], ], 'television' => [ 'label' => 'Television', 'uri' => '#', 'liClass' => 'television', 'type' => LrphptPage\UriPage::class, 'pages' => [ 'television1' => [ 'label' => 'Flat Superscreen', 'uri' => '#', 'type' => LrphptPage\UriPage::class, ], 'television2' => [ 'label' => 'Gigantic LED', 'uri' => '#', 'type' => LrphptPage\UriPage::class, ], 'television3' => [ 'label' => '3D Experience', 'uri' => '#', 'type' => LrphptPage\UriPage::class, ], ], ], 'camera' => [ 'label' => 'Cameras', 'uri' => '#', 'liClass' => 'camera', 'type' => LrphptPage\UriPage::class, 'pages' => [ 'camera1' => [ 'label' => 'Smart Shot', 'uri' => '#', 'type' => LrphptPage\UriPage::class, ], 'camera2' => [ 'label' => 'Power Shooter', 'uri' => '#', 'type' => LrphptPage\UriPage::class, ], 'camera3' => [ 'label' => 'Easy Photo Maker', 'uri' => '#', 'type' => LrphptPage\UriPage::class, ], ], ], ], ], 'magazines' => [ 'label' => 'Magazines', 'uri' => '#', 'liClass' => 'magazines', 'type' => LrphptPage\UriPage::class, 'pages' => [ 'magazines1' => [ 'label' => 'National Geographic', 'uri' => '#', 'type' => LrphptPage\UriPage::class, ], 'magazines2' => [ 'label' => 'Scientific American', 'uri' => '#', 'type' => LrphptPage\UriPage::class, ], 'magazines3' => [ 'label' => 'The Spectator', 'uri' => '#', 'type' => LrphptPage\UriPage::class, ], ], ], ] ], ];
MVC 视图中的使用
<?=$this->navigation('default') ->hcOffCanvasMenu() ->setUlClass('first-nav') // Optional setting to use with LmcRbac route guard. ->setAuthorizationService($this->LmcRbacAuthorizationServiceHelper()) ; ?>