Download the PHP package darkling/nette-menu without Composer
On this page you can find all versions of the php package darkling/nette-menu. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download darkling/nette-menu
More information about darkling/nette-menu
Files in darkling/nette-menu
Package nette-menu
Short Description Menu for Nette framework
License MIT
Homepage https://github.com/Carrooi/Nette-Menu
Informations about the package nette-menu
Nette menu
Nette component for creating menus, breadcrumbs and sitemaps.
Requirements
- PHP >=7.1
- Nette ^2.4
Installation
Install package with composer:
Register as nette extension:
Basic usage
You can write menu links as associated multi dimensional arrays. Because of this you are able to create any structure of menus and submenus you may need.
That structure in neon config will generate two menus:
front:
- Home (action:
Front:Home:
) - Books (link:
#
)- All (action:
Front:Books:all
) - Featured (action:
Front:Books:featured
)
- All (action:
admin:
- Users (action:
Admin:Users:
) - Books (action:
Admin:Books:
)
Templates
This package includes 3 default templates (menu, breadcrumbs, sitemap). However only the default sitemap template should be used in real project. The other two templates should only help you in the beginning with building your own templates which will fit your's website look.
- menu.latte
- breadcrumbs.latte
- sitemap.latte
Changing templates can be done in your menu configuration:
As you can see, each menu can have different templates.
Visibility of items
It may be useful to hide some links in specific situations. For that we have the visibility
option on items where
you can tell on which template the link should be visible.
Mark active item via regex
Menu item can be labeled as active by a regular expression (or array of regular expressions) that is compared to the entire Presenter's name and action.
You can set your regular expression via include
setting.
Translations
When displaying title of link in some template, we always work with translated titles.
You have three options for translator:
- Do nothing: Original
ReturnTranslator
class will be used. This translator just returns the given text. - Set translator manually: Provide your own implementation of
Nette\Localization\ITranslator
. - Set translator to
true
: Menu extension will try to find your translator in DI container automatically.
Custom data
Every link can contain additional data which can be later used eg. in your custom latte templates.
Authorization
Sometimes you may want to hide some links based on custom rules, that includes for example authorization from nette.
This menu package uses custom IAuthorizator
interface which you can use to write your own authorizators.
Link generator
When you want to display a link in your template it uses the ILinkGenerator
interface to generate it from the data
in your menu config. If you want to change the default logic (which uses link
method from nette) you can just implement
your custom link generator.
You can also override link generator later for some subtree of links:
Menu loader
If you want to build your menu maybe from database instead of neon config, you can do that by creating IMenuLoader
class.
See the default ArrayMenuLoader how it works.
Changelog
-
2.1.0
-
2.0.0
- Refactoring - complete rewrite
-
1.1.1
- Move under Carrooi organization
-
1.1.0
- Support for ACL permissions (thanks whipsterCZ)
- Support for generating sitemap (thanks whipsterCZ)
-
1.0.4
- Added
hasIcon
andhasCounter
methods - Support for "absolute" targets #6
- Added
-
1.0.3
- Added shortcut methods for working with item's data #5
-
1.0.2
- Support for "dynamic" modules in includes option #4
-
1.0.1
- 1.0.0
- First version
All versions of nette-menu with dependencies
nette/di Version ^3.0
nette/utils Version ^3.0
nette/application Version ^3.0
nette/http Version ^3.0