chrizus / arraymenu
Create a nested menu from an array with list items.
dev-master
2023-10-16 19:58 UTC
Requires
- php: ^8.1
Requires (Dev)
- phpunit/phpunit: ^10
This package is auto-updated.
Last update: 2025-02-16 22:48:40 UTC
README
This package has been forked for personal usage. please visit the priginal package at wtabata/arraymenu
ArrayMenu 2
Build Menu/Navbar from Bootstrap 5 with array[] o/
Install
composer require chrizus/arraymenu
Mode Simple
Standard HTML list structure will be built
$array = [ 'home' => [ 'name' => 'Label for Home', 'link' => '#', ], [ /* << see, here don't have key. no matter. just for help u */ 'name' => 'Label for Contact' ], ]; $menu = new \BergPlaza\ArrayMenu\Simple($array); echo $menu;
output
<ol class="more_class my_class"> <li class=""><a class="" href="#">Label for Home</a></li> <li class="">Label for Contact</li> </ol>
Default List Tag
<ul> <!-- init - primary tag --> <li> <!-- item - secondary tag --> <a href="#"> - </a> <!-- link - content --> </li> </ul>
Two ways to Configure tags
global
//set primary Tag $menu->setInit(['tag'=>'ol', 'class' =>'my_class']); //set secondary Tag $menu_b->setItem(['tag'=>'li', 'class' =>'my_class_for_item other']);
or per item
$array = [ 'config' => [ //set primary Tag 'tag' => 'ol', 'class' => 'my_class' ], 'home' => [ 'config' => [ //set secondary Tag 'tag' => 'dd', 'class' =>'my_class_for_item other' ], 'name' => 'Label for Home', 'link' => '#', ], ];
Mode Bootstrap 5
Bootstrap 5 navbar structure will be built
$array = [ 'home' => [ 'name' => 'Label for Home', 'link' => '#', 'class' => 'nav-link', ], 'contact' => [ 'name' => 'Label for Contact', 'link' => '#', 'class' => 'nav-link', ], 'sitemap' => [ 'name' => 'Label for Sitemap', 'link' => '#', 'class' => 'nav-link active', ] ]; $menu = new \BergPlaza\ArrayMenu\Bootstrap($array, $config_bootstrap = []); echo $menu;
Default Config Bootstrap 5
$config_bootstrap = [ 'position' => 'default', 'color' => 'bg-primary', 'container' => 'container', 'brand' => [ 'name' => 'WT.dev', 'image' => false, 'link' => 'https://wtabata.com' ], 'off_canvas' => false ];
TO DO
Docs
- usage simple
- usage with bootstrap
- defaults tags
- custom tags
- options base
- options bootstrap
Base
- other non-standard tags
Bootstrap
- scroll