lm-commons/lmc-bootstrap-menu

This repository can generate nested bootstrap menu based on ul li tag. More may come later. Thanks!

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

This package is auto-updated.

Last update: 2024-11-24 14:31:32 UTC


README

This repository will contain bootstrap menu integration with laminas-mvc.

Pre-Requisites

You need to have bootstrap css and js file included in your layout.phtml. If not, you can still be able to see the generated html.

Introduction

This package generates a bootstrap menu based on the configuration given in your application. Which should be compatible with Laminas-Navigation. Because this package extends Laminas-Navigation therefore the configuration should match with Laminas-Navigation. This package came into existence with the help of Frank Brückner. Thanks for the help Frank Brückner. My first contribution to Laminas MVC.

Installation using Composer

composer require lm-commons/lmc-bootstrap-menu

Registering the modules in your application

<?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',
    ],
];

Menu Container Array

<?php

// Application/config/module.config.php
return [

    // ...
    'navigation' => [
      'default' => [
        'home' => [
           'label' => 'Home',
           'route' => 'home',
        ],
        'category' => [
          'label' => 'Category',
          'uri' => '#',
          'pages' => [
            'php' => [
              'label' => 'PHP',
              'uri' => 'https://www.php.net',
            ],
            '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',
            ],
          ],
        ]
      ]
    ],
];

Usage in MVC View

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