项目作者: depa-berlin

项目描述 :
PSR-15 Middleware Navigation for Zend Expressive
高级语言: PHP
项目地址: git://github.com/depa-berlin/Middleware-Navigation.git
创建时间: 2019-04-28T13:48:58Z
项目社区:https://github.com/depa-berlin/Middleware-Navigation

开源协议:MIT License

下载


Middleware-Navigation

Software License
StyleCI
Coverage Status

Installation

Run the following to install this library:

  1. $ composer require depa/middleware-navigation

Documentation

After installing the module, you have to implement the navigation-middleware into your pipeline,
so you basically add this line above the RouteMiddleware:

  1. $app->pipe(depa\NavigationMiddleware\Middleware\NavigationMiddleware::class);


To create a navigation, use the navigation.global.php (it’s inside the config folder)
as your basic (put it into config\autoload)

The basic structure of a menu-item must look like this:

  1. '{navigation_Name}' => [
  2. 'route' => '{route_name}', //route-name which is set in routes.php
  3. ]


if you want to add attributes to a menu-item (to the ul element), do this:

  1. '{navigation_Name}' => [
  2. 'attributes' => [...], //possibilitys in attributes-table described (at the bottom of the doc)
  3. ]


if you want to add link-attributes to a menu-item (to the a element), do this:

  1. '{navigation_Name}' => [
  2. 'linkAttributes' => [...], //possibilitys in link-attributes-table described (at the bottom of the doc)
  3. ]


if you want to add child-items to a menu-item, do this (you can use as many as you want):

  1. '{navigation_Name}' => [
  2. 'childs' => [...], //build the same as a normal menu-item
  3. ]


if you want to force a link-direction to an item then add this:

  1. '{navigation_Name}' => [
  2. 'uri' => '{https://www.designpark.de}',
  3. ]


a menu-item which contains any of the given examples could look like this:

  1. '{navigation_Name}' => [
  2. 'route' => '{route_name}',
  3. 'uri' => '{https://www.designpark.de}',
  4. 'attributes' => [
  5. 'id' => '{some_id}',
  6. 'class' => ['{class1} {class2}'],
  7. ],
  8. 'linkAttributes' => [
  9. 'id' => '{some_id}',
  10. 'class' => '{class_1} {class2}',
  11. ],
  12. 'childs' => [
  13. '{childNavigation_Name}' => [
  14. 'route' => '{route_name}',
  15. 'uri' => '{https://www.designpark.de}',
  16. 'attributes' => [],
  17. 'linkAttributes' => [],
  18. 'childs' => [],
  19. ]
  20. ]
  21. ]


The example provided above would output the following HTML:

  1. <ul>
  2. <li id="{some_id} class="{class1 class2} first last">
  3. <a href="{https://www.designpark.de}">{navigationName}</a>
  4. <ul class="menu_level_1">
  5. <li class="first last">
  6. <a href="{https://www.designpark.de}">{childNavigationName}</a>
  7. </li>
  8. </ul>
  9. </li>
  10. </ul>

which would look like this:


Attributes you could use and what they do:

Attribute Description Example
Id Sets the id of the element ‘id’ => ‘some_id’
class Sets the classes of the elements ‘class’ => ‘class1 class2’


Link-Attributes you could use and what they do:

Attribute Description Example
Id Sets the id of the element ‘id’ => ‘some_id’
Class Sets the classes of the element ‘class’ => ‘class1 class2’
Target Sets the target-window of the element ‘target’ => ‘_blank’

we did not listed every link-/attribute, take a closer look at knpLabs/KnpMenu for more informations!

Credits

This bundle is inspired by Zend Framework. It has been developed by designpark.

License

The MIT License (MIT). Please see License File for more information.