You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Allows you to easily define and parse menus inside templates, configuration based approach.
18
17
19
18
## Installation
@@ -33,7 +32,6 @@ Register `NavigationMiddleware` in your middleware pipe between the routing and
33
32
34
33
Locate dot-navigation's distributable config file `vendor/dotkernel/dot-navigation/config/autoload/navigation.global.php.dist` and duplicate it in your project as `config/autoload/navigation.global.php`
35
34
36
-
37
35
## Components
38
36
39
37
A menu, or navigation container, is a class implementing the \RecursiveIterator interface. It has a hierarchical structure, with nodes called pages(see the `Page` class) that may have children. It is basically a tree
@@ -48,7 +46,6 @@ Attributes are key value pairs that defines the menu item. They are usually inse
48
46
49
47
A `NavigationService` class, is the service that handles all defined menu container. It can fetch the container from its provider, check if a page is active or not and get the page's generated URI.
50
48
51
-
52
49
## Container providers
53
50
54
51
Each menu can be created from different sources. The responsibility of creating a menu container from the source falls on a container provider.
@@ -57,7 +54,6 @@ Each provider must implement the interface `ProviderInterface` and be registered
57
54
58
55
We offer just one provider for now, `ArrayProvider`, that is able to fetch and create a menu container from a php array that is defined in the configuration file.
59
56
60
-
61
57
## NavigationRenderer
62
58
63
59
Used to render the navigation container in a displayable format. It can render a simple HTML ul list or use a partial template, to render the menu in a template engine.
@@ -66,14 +62,14 @@ The partial method is usually the more flexible one, custom rules can be defined
66
62
67
63
If you are using twig, there is already a twig extension provided in package dot-twigrenderer, that you can use to easily parse the menus inside your templates
68
64
69
-
70
65
When using the partial method, the template will receive as parameters the container, the navigation service and any extra parameters set by the developer.
71
66
72
67
Navigation containers are referred, when parsed, by their name, as defined in the configuration file.
73
68
74
69
## Required page options and attributes
75
70
76
71
The following are options that each page should define in the configuration
72
+
77
73
*`label` - the text of the menu item
78
74
*`route` or `uri` - defines the route or link the menu item will have
79
75
*`permission` - can be used optionally, if authorization service is present, in order to omit menu items that are not authorized to visit.
A menu, or navigation container, is a class implementing the \RecursiveIterator interface. It has a hierarchical structure, with nodes called pages(see the `Page` class) that may have children. It is basically a tree
4
+
5
+
A Page extends the NavigationContainer class. The NavigationContainer is the top most node which represents the entire menu. The children of this node are Page instances that defines each navigation item.
6
+
7
+
A page has a reference to its parent, and can have options and attributes. There are no limitation on what is accepted as options or attributes.
8
+
9
+
Options can be any piece of information that describes a page. Some predefined options exists, in order for the navigation module to work seamlessly with other dot modules.
10
+
11
+
Attributes are key value pairs that defines the menu item. They are usually inserted as html attributes when parsing the menu, but of course, this is implementation specific.
12
+
13
+
A `NavigationService` class, is the service that handles all defined menu container. It can fetch the container from its provider, check if a page is active or not and get the page's generated URI.
After installation, register `dot-navigation` in your project by adding the below line to your configuration aggregator (usually: `config/config.php`):
4
+
5
+
Dot\Navigation\ConfigProvider::class,
6
+
7
+
Locate dot-navigation's distributable config file `vendor/dotkernel/dot-navigation/config/autoload/navigation.global.php.dist` and duplicate it in your project as `config/autoload/navigation.global.php`
0 commit comments