Skip to content

Commit 287c0dc

Browse files
Completed the overview doc
1 parent d240c94 commit 287c0dc

File tree

1 file changed

+42
-1
lines changed

1 file changed

+42
-1
lines changed

docs/overview.md

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,45 @@
33
Navigation menus are essential parts of applications. This library offers PHP developers tools to create, organize,
44
and 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+
```

0 commit comments

Comments
 (0)