Download the PHP package mix8872/yii2-menu without Composer
On this page you can find all versions of the php package mix8872/yii2-menu. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package yii2-menu
Yii2-menu module
Module for create menu on you website.
Installation
The preferred way to install this extension is through composer.
Either run
or add
to the require
section of your composer.json
.
Then you must run migration by running command:
yii migrate --migrationPath=@vendor/mix8872/yii2-menu/src/migrations
Configure
To configure module please add following to the modules section of main config:
Backend:
Usage
After configuring go to the url /menu/default/index
and press Add button,
fill the name, code and description of your new menu;
Now you can add menu items by pressing 'plus' green button in right side.
Menu items can be two types:
- simple
- from model
Simple
Simple menu item is the ordinary item with url and title. That's all.
From model
That's 'magic' menu item which get menu items from ActiveRecord model
and replaces itself with the received data.
This menu item has next not ordinary fields:
- Url - base url, unlike a 'Simple', it contains base and dynamic parts of url
the dynamic part must be enclosed in curly brackets and must be the same as Url attribute
for example:/news/{code}
, here/news/
- is a basic part and{code}
- is a dynamic part
then Url attribute must declared ascode
- Model class - here you should specify full model class name (of course with namespace)
- Url attribute - this is attribute name which will be used in the end part of url
- Title attribute - attribute from which the menu item title will be taken
you can specify the name separated by a dot:content.title
,
then the value will be taken from the relative table, but you can set only one dot - Description attribute - attribute from which the menu item description will be taken
you can specify the name separated by a dot:content.description
,
then the value will be taken from the relative table, but you can set only one dot - Selection parameters - there you can declare SQL-like parameters for selection of items from model
for example:WHERE status = 1 ORDER BY id DESC LIMIT 2
!!! BE CAREFUL, IT IS EXPERIMENTAL FEATURE AND CAN BREAK YOUR APP !!!
Next you may echo widget with its config.
The simplest case is:
But widget can be configured in more detail. Next options is available:
Events
On adding, updating and deletion files will generates next events:
- EVENT_AFTER_CREATE = 'menuAfterCreate' - fires after creation new menu
- EVENT_AFTER_DELETE = 'menuAfterDelete' - fires after deletion menu
- EVENT_AFTER_DELETE_ITEM = 'menuAfterDeleteItem' - fires after deletion menu item
- EVENT_AFTER_ADD_ITEM = 'menuAfterAddItem' - fires after add menu item
- EVENT_AFTER_SORT = 'menuAfterSort' - fires after sort menu items
- EVENT_AFTER_UPDATE = 'menuAfterUpdate' - fire after update menu,
also fires when EVENT_AFTER_ADD_ITEM, EVENT_AFTER_DELETE_ITEM and EVENT_AFTER_SORT
You can intercept events in the module configuration as in the example above.
All versions of yii2-menu with dependencies
ext-mbstring Version *
ext-intl Version *
yiisoft/yii2-bootstrap4 Version ^2.0
yiisoft/yii2-jui Version ~2.0
paulzi/yii2-nested-sets Version ^1.0
rmrevin/yii2-fontawesome Version ~3.5
bower-asset/jquery-toast-plugin Version dev-master