Download the PHP package dewsign/nova-navigation without Composer
On this page you can find all versions of the php package dewsign/nova-navigation. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download dewsign/nova-navigation
More information about dewsign/nova-navigation
Files in dewsign/nova-navigation
Package nova-navigation
Short Description Navigation/Menu manager for Laravel Nova
License MIT
Informations about the package nova-navigation
Navigation/Menu manager for Laravel Nova
Installation
composer require dewsign/nova-navigation
php artisan migrate
Usage
To get started, you will need to create your first Navigation area. E.g. Header or Footer navigation. You are free to structure the files as you wish or you can use the conventions from the examples if you prefer.
We simply use the default Nova folder to register our new navigation as it will load automatically.
The $zone
is used to differentiate the various navigation areas in the database and code and avoids requiring new tables for each new navigation area.
Your new navigation zone will now be available within Nova, with the default custom link item as the only option.
Outputting the navigation (Blade)
Navigation Blade Directive
A blade directive is included to render navigation zones primarily through views. A default unordered list view is included and can be published from the package.
Inside your blade view template or layout ...
This will render all navigation items recursively using the default view. To create a custom view you can make a new blade view in resources/views/vendor/nova-navigation/zone//my-zone.blade.php
.
You can use the default view as a template.
You will notice that it renders the same view for each level of navigation nested within the parent item. If you don't want this you will need to manually loop through the child items. You can access any sub-items through the navigations
relationship.
The view
property renders the assigned blade view for the navigation item type. The default custom item view can be published and modified through the vendor views resources/views/vendor/nova-navigation/custom.blade.php
If you don't want to render the navigation item's default view, you can manually build an inline view and use the label
and action
properties.
Link Types
The packages attempts to determine the type of link entered and returns this on the item through the linkType
attribute. You can access this within the view
using $item->linkType
. This can be useful for adding icons to links for example.
Type | Description |
---|---|
mailto | An email link |
tel | A telephone link |
download | A link pointing to a download. You can customise the file extensions which are treated as downloads in the config. |
external | A link pointing off-site |
internal | A link pointing to a URL within your site |
Extending
You can create your own navigation item types by creating a couple of new files and loading them in. This is useful for making your content types available as selectable navigation items instead of manually typing in custom URLs. As an example, if you have a Blog and want the user to be able to select an article or category to link to.
You will need:
- An Eloquent Model, complete with migration
- A Nova resource to manage the content
- A blade view to render the item
Next you need to tell the system how you want to render the category navigation item. Create a new view at the location specified in the Model (in this example resources/views/vendor/nova-navigation/category.blade.php
). Or you can set the view in the model to the default nova-navigation::custom
if you simply want to render the same layout for all navigation items.
$model
references the Category Model we created. To access the actual blog category you can refer to the relationship $model->category
if you wanted to include additional details in your view. E.g.
Finally, load the new navigation item through the novanavigation
config
User can now add a Category
navigation item and select an existing category to link to. The benefit is that when the category changes, the navigation item also reflects these.
Hyperlinks Repeater Blocks
If you are using Nova Repeater Blocks to build out your content, you may want to include a repeater block which acts like a navigation zone to add inline links. Add the included NrbHyperlinks
for your repeater blocks.
This will render each navigation item using their respective views. The wrapper for each item can be customised by creating new templates in the views/vendor/nova-navigation/hyperlinks
directory. You can publish and modify the default if required.
All versions of nova-navigation with dependencies
laravel/framework Version >=5.0.0
maxfactor/support Version ^2.0.0
benjaminhirsch/nova-slug-field Version ^1.0
silvanite/nova-field-cloudinary Version ^1.0
dewsign/nova-repeater-blocks Version ^1.3.3
epartment/nova-dependency-container Version ^1.1
silvanite/brandenburg Version ^1.0
silvanite/nova-field-hidden Version ^1.0