Menus and Menu Builder
With Voyager you can easily create menus for your application. In fact the Voyager admin is using the menu builder for the navigation you use on the left hand side.
You can view your current Menus by clicking on the Tools->Menu Builder button. You can add, edit, or delete any current menu. This means that you can create a new menu for the header, sidebar, or footer of your site. Create as many menus as you would like.
When you are ready to add menu items to your menu you can click on the builder button of the corresponding menu:
![](https://voyager-docs.devdojo.com/~gitbook/image?url=https%3A%2F%2F1486345001-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F-LOZ_fG1zbRQxFD0p8uB-4025916689%252Fuploads%252Fgit-blob-b95ebe023e73d970e76eadaec69d2e4cf6525682%252Fmenu_1.jpg%3Falt%3Dmedia%26token%3D77f682d2-a11d-46d4-9981-7e3a07e21498&width=768&dpr=4&quality=100&sign=a6ad8fbd&sv=1)
This will take you to the Menu Builder where you can add, edit, and delete menu items.
![](https://voyager-docs.devdojo.com/~gitbook/image?url=https%3A%2F%2F1486345001-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F-LOZ_fG1zbRQxFD0p8uB-4025916689%252Fuploads%252Fgit-blob-7f33286ef38de50c042010f078c86fb4c06767ff%252Fmenu_2.jpg%3Falt%3Dmedia%26token%3D66b8bd99-ea62-4f8a-ac73-e8793da9a4d7&width=768&dpr=4&quality=100&sign=28cedc33&sv=1)
After creating and configuring your menu, you can easily implement that menu in your application. Say that we have a menu called main
. Inside of any view file we could now output the menu by using the following code:
This will output your menu in an unstyled unordered list. If you do use bootstrap to stylize your web app you can pass a second argument to the menu display method telling it that you want to stylize the menu with bootstrap styles like so:
Taking it one more step further you can even specify your own view and stylize your menu however you would like. Say for instance that we had a file located at resources/views/my_menu.blade.php
, which contained the following code:
Then anywhere you wanted to display your menu you can now call:
And your custom menu will now be output.
Menu as JSON
If you dont want to render your menu but get an array instead, you can pass _json
as the second parameter. For example:
This will give you a collection of menu-items.
Last updated