1. Go to this page and download the library: Download outl1ne/nova-page-manager library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
outl1ne / nova-page-manager example snippets
// in app/Providers/NovaServiceProvider.php
public function tools()
{
return [
// ...
new \Outl1ne\PageManager\PageManager()
->withSeoFields(fn () => []), // Optional
];
}
// Name displayed in CMS
public function name(Request $request)
{
return parent::name($request);
}
// Fields displayed in CMS
public function fields(Request $request): array
{
return [];
}
// Resolve data for serialization
public function resolve($page): array
{
// Modify data as you please (ie turn ID-s into models)
return $page->data;
}
// Page only
// Optional suffix to the route (ie {blogPostName})
public function pathSuffix() {
return null;
}
// in /config/nova-page-manager.php
// ...
'templates' => [
'pages' => [
'home-page' => [
'class' => '\App\Nova\Templates\HomePageTemplate',
'unique' => true, // Whether more than one page can be created with this template
],
],
'regions' => [
'header' => [
'class' => '\App\Nova\Templates\HeaderRegionTemplate',
'unique' => true,
],
],
],
// ...
// in /config/nova-page-manager.php
// ...
'locales' => [
'en' => 'English',
'et' => 'Estonian',
],
// OR
'locales' => function () {
return Locale::all()->pluck('name', 'key');
},
// or if you wish to cache the configuration, pass a function name instead:
'locales' => NPMConfiguration::class . '::locales',
// ...
// in /config/nova-page-manager.php
'base_url' => 'https://webshop.com', // Will add slugs to the end to make the URLs
// OR
'base_url' => function ($page) {
return env('FRONTEND_URL') . '/' . $page->path;
},
// in app/Providers/NovaServiceProvider.php
public function boot()
{
Nova::serving(function () {
Nova::provideToScript([
// ...
'customLocaleDisplay' => [
'en' => <img src="/flag-en.png"/>,
'et' => <img src="/flag-et.png"/>,
]
]);
});
}
// In your PageTemplate class
public function fields() {
return [
Panel::make('Some panel', [
Text::make('Somethingsomething'),
Text::make('Sub-translatable', 'subtranslatable')
->translatable(),
])
->translatable(false),
];
}