Download the PHP package cyber-gh/nova-page-manager without Composer
On this page you can find all versions of the php package cyber-gh/nova-page-manager. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package nova-page-manager
Nova Page Manager
This Laravel Nova package allows you to create and manage pages and regions. The package is geared towards headless CMS's.
Requirements
- Laravel Nova <= 2.0.7 || >= 2.0.10
Laravel Nova 2.0.8 and 2.0.9 are breaking for Nova Page Manager.
Features
- Pages and Regions management
- Programmatically created templates for Pages and Regions
- Multilanguage support
- Optional pages draft support
Screenshots
Installation
Install the package in a Laravel Nova project via Composer and run migrations:
Publish the nova-page-manager
configuration file and edit it to your preference:
Register the tool with Nova in the tools()
method of the NovaServiceProvider
:
Usage
Creating templates
Templates can be created using the following Artisan command:
This will ask you a few additional details and will create a base template in App\Nova\Templates
.
The template base has a few properties:
Registering templates
All your templates have to be registered in the config/nova-page-manager.php
config file.
Defining locales
Locales can be defined similarly to how templates are registered. The config accepts a dictionary of locales.
Enabling page draft feature
Draft feature allows you to create previews of pages before publishing them. By default this feature is not installed, but you can install nova-drafts with the following command.
Overriding SEO fields
The default SEO fields can be overridden using the configuration file. The configuration file contains the key seo_fields
which accepts an array (or a callable which returns an array) of fields.
Modify page path
To add a locale prefix to page paths or to modify page paths for any other reason on the Page
model, supply a callback to page_path
in the config.
Add links to front-end pages
To display a link to the actual page next to the slug, add or overwrite the closure in config/nova-page-manager.php
for the key page_url
.
Overwrite package resources
You can overwrite the package resources (Page & Region) by setting the config options in nova-page-manager.php
.
Note: If you create your resources under App\Nova
namespace, to avoid key duplication you must manually register all other resources in the NovaServiceProvider
. See registering resources on Nova documentation.
Modifying Field values
All fields have a registered macro resolveResponseUsing(callable $resolveResponseCallback)
which allows you to modify the field's value before it is returned through the Page Manager's API (ie nova_get_page()
).
The signature for the callback is: function ($value, $templateModel) { ... }
.
For example:
Helper functions
nova_get_pages_structure(\$previewToken)
The helper function nova_get_pages_structure($previewToken)
returns the base pages structure (slugs, templates, child-parent relationships) that you can build your routes upon in the front-end. This does not return the pages' data. Preview token is optional and used only if draft feature is enabled. By default drafts will not be included in the structure.
Example response:
nova_get_regions()
The helper function nova_get_regions()
returns all the regions and their data.
Example response:
nova_get_page(\$pageId)
The helper function nova_get_page($pageId)
finds and returns the page with the given ID.
Example response for querying page with ID 3
(nova_get_page(3)
):
nova_get_page_by_slug($slug, $previewToken)
The helper function nova_get_page_by_slug($slug, $previewToken)
finds and returns the page with the given slug. Preview token is optional and used to query draft pages when draft feature is enabled.
Example response for querying page with slug /home
and preview token L1SVNKDzBNVkBq8EQSna
(nova_get_page_by_slug("home", "L1SVNKDzBNVkBq8EQSna")
):
nova_page_manager_get_page_by_path($slug, $previewToken, \$locale)
The helper function nova_page_manager_get_page_by_path($slug, $previewToken, $locale)
finds and returns the page with the given path and all of it's parents. Preview token and locale are optional. Preview token is used to query draft pages when draft feature is enabled.
Example response for querying page with slug /home/about
and preview token L1SVNKDzBNVkBq8EQSna
(nova_page_manager_get_page_by_path("home/about", "L1SVNKDzBNVkBq8EQSna")
):
Credits
License
Nova page manager is open-sourced software licensed under the MIT license.
All versions of nova-page-manager with dependencies
laravel/nova Version ^2.9 || ^3.0
optimistdigital/nova-locale-field Version ^2.0.1
doctrine/dbal Version ^2.9