Download the PHP package sclaravel/menus without Composer
On this page you can find all versions of the php package sclaravel/menus. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download sclaravel/menus
More information about sclaravel/menus
Files in sclaravel/menus
Informations about the package menus
Laravel Menus
- Installation
- Creating A Menu
- Menu Item
- Menu Attributes
- Menu Dropdown
- Menu Dropdown Milti Level
- Menu Divider
- Dropdown Header
- Ordering Menu Item
- Make Lots of Menu
- Menu Presenter
- The Available Presenter
- Make A Custom Presenter
- Register A New Menu Style
- View Presenter
- The Available View Presenter
- Rendering Menu
- Menu Inheritance
- Menu Instance
- Finding Menu Item
- Modifying Menu
- Set sub-active
Installation
You can install the through composer command line.
Publish package's assets by running:
Creating A Menu
You can define your menus in app/Menus/Left.php
file. That file will loaded automatically by this package.
To create a menu, simply call the create
or make
method from Menu
facade. The first parameter is the menu name and the second parameter is
callback
for defining menu items.
`
As explained before, we can defining menu item in the callback by accessing $menu
variable, which the variable is instance of
TysonLaravel\Menus\Builder
class.
To defining a plain URL, you can use ->url()
method.
If you have named route, you define the menu item by calling ->route()
method.
You can also defining the menu item via array by calling ->add()
method.
Attibutes | Detail |
---|---|
target |
|
icon |
To create a dropdown menu, you can call to ->dropdown()
method and passing the first parameter by title of dropdown and the second parameter by closure callback that retrive $sub
variable. The $sub
variable is the the instance of TysonLaravel\Menus\MenuItem
class.
You can also create a dropdown inside dropdown by using ->dropdown()
method. This will allow to to create a multilevel menu items.
You may also define a divider for each menu item. You can divide between menu item by using ->divider()
method.
You may also add a dropdown header for the specified menu item by using ->header()
method.
You may order the menu by specify order
parameter.
You may also set the order value by calling ->order
method.
By default ordering feature is disabled. You can enable the ordering
feature in your config file. Just update value of ordering
config to true
and now your menu will ordered by order
key.
You may also enable or disable menu ordering for each menu via ->enableOrdering
and ->disableOrdering
method.
You can also create a lots of menu with different name and menu items.
Menu Presenter
This package included with some presenter classes that used for converting menu to html tag. By default the generated menu style is bootstrap navbar
. But, there are also several different menu styles.
You can apply the menu style via ->style()
method.
Or you can set which presenter to present the menu style via ->setPresenter()
method.
You can also set which style of presenter when you rendering a menu.
The List of Available Menu Presenter Class
Name | Presenter Class |
---|---|
navbar |
TysonLaravel\Menus\Presenters\Bootstrap\NavbarPresenter |
navbar-right |
TysonLaravel\Menus\Presenters\Bootstrap\NavbarRightPresenter |
nav-pills |
TysonLaravel\Menus\Presenters\Bootstrap\NavPillsPresenter |
nav-tab |
TysonLaravel\Menus\Presenters\Bootstrap\NavTabPresenter |
sidebar |
TysonLaravel\Menus\Presenters\Bootstrap\SidebarMenuPresenter |
navmenu |
TysonLaravel\Menus\Presenters\Bootstrap\NavMenuPresenter |
You can create your own presenter class. Make sure your presenter is extends to TysonLaravel\Menus\Presenters\Presenter
and implements
to 'TysonLaravel\Menus\Presenters\PresenterInterface'.
For example, this is zurb-top-bar
presenter.
To use this costum presenter, you can use the setPresenter
method.
Menu style is like an alias to a presenter. You can register your style from your costum presenter in the configuration file in config/menus.php
.
Now, you can use a style like this.
View Presenter
If you don't like to use presenter class, you use view presenter instead. We can set which view to present the menus by calling ->setView()
method.
The List of Available View Presenter
View Name | Menu Style |
---|---|
menus::default |
Bootstrap Navbar (default) |
menus::navbar-left |
Bootstrap Navbar Left |
menus::navbar-right |
Bootstrap Navbar Right |
menus::nav-tabs |
Bootstrap Nav Tabs |
menus::nav-tabs-justified |
Bootstrap Nav Tabs Justified |
menus::nav-pills |
Bootstrap Nav Pills |
menus::nav-pills-stacked |
Bootstrap Nav Pills Stacked |
menus::nav-pills-justified |
Bootstrap Nav Pills Justified |
menus::menu |
Plain Menu |
Rendering Menu
To render the menu you can use render
or get
method.
You can also set which style to present the menu in the second parameter.
Or you may also set which view to present the menu.
The Menu Instance
Sometimes, maybe we need to add a new additional menu from controller or other place. To get an instance of an existing menu, you can use the instance
method.
Finding Menu Item
To find menu item, you can use findBy
method from TysonLaravel\Menus\MenuBuilder
class.
You may also use whereTitle
helper method to find a specific menu item. Also, you can add other child menu item in the callback that located in the second argument in whereTitle
method.
Modifying Menu
After we create a menu, maybe we need to add other additional menus. You may modifying menu via ->modify
method.
Set active in sub menu
Use ->subActive(['routeName'])