File tree Expand file tree Collapse file tree 1 file changed +42
-1
lines changed
Expand file tree Collapse file tree 1 file changed +42
-1
lines changed Original file line number Diff line number Diff line change 33Navigation menus are essential parts of applications. This library offers PHP developers tools to create, organize,
44and manage menus using PHP classes.
55
6- !> Work In progress
6+ ``` php
7+ use Konekt\Menu\Facades\Menus
8+
9+ $sidebar = Menus::create('sidebar');
10+ $sidebar->addItem('home', 'Home', '/');
11+ $sidebar->addItem('about', 'About', '/about');
12+ ```
13+
14+ This library focuses on the backend, PHP part of menu building, including the HTML generation.
15+ The frontend framework, and the menu styling is up to the application, however there are several out-of-the box
16+ renderers that can be used as a base:
17+
18+ - ` ul ` + ` li ` renderer,
19+ - ` ol ` + ` li ` renderer, and
20+ - ` div ` -based renderer.
21+
22+ ``` php
23+ Menu::get('sidebar')->render('ul');
24+ //= """
25+ // <ul >\n
26+ // \t<li class =" active" ><a href =" http://localhost:8080" >Home</a ></li >\n
27+ // \t<li ><a href =" http://localhost:8080/about" >About</a ></li >\n
28+ // </ul >\n
29+ ```
30+
31+ Besides these, you can also simply use the menus in Blade templates and render them using foreach loops:
32+
33+ ``` blade
34+ <div class="menu">
35+ @foreach($menu->items as $item)
36+ @if($item->isAllowed())
37+ <div class="menu-item">
38+ @if($item->hasLink)
39+ <a href="{!! $item->url() !!}">{{ $item->title }}</a>
40+ @else
41+ {{ $item->title }}
42+ @endif
43+ </div>
44+ @endif
45+ @endforeach
46+ </div>
47+ ```
You can’t perform that action at this time.
0 commit comments