lm-commons/lmc-bootstrap-menu

此仓库可以根据 ul li 标签生成嵌套的 bootstrap 菜单。未来可能会有更多功能。谢谢!

v1.0.0 2022-10-24 08:40 UTC

This package is auto-updated.

Last update: 2024-08-24 13:57:27 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 lm-commons/lmc-bootstrap-menu

在您的应用程序中注册模块

<?php
return [
    'modules' => [
        // ...
        'Laminas\Navigation', // <-- Add this line if not present
        'LmcBootstrapMenu', // <-- 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',
        ],
        'category' => [
          'label' => 'Category',
          'uri' => '#',
          'pages' => [
            'php' => [
              'label' => 'PHP',
              'uri' => 'https://php.ac.cn',
            ],
            'laminas' => [
              'label' => 'Laminas',
              'uri' => 'https://getlaminas.org/',
            ],
            'devider' => [
               'label' => '--devider', // most important
               'route' => '#',
            ],
            'magento' => [
              'label' => 'Magento',
              'uri' => 'https://business.adobe.com/products/magento/magento-commerce.html',
            ],
          ],
        ]
      ]
    ],
];

在 MVC 视图中使用

<?=$this->navigation('default')
                    ->bootstrapMenu()
                    ->setUlClass('navbar-nav'); ?>