PHP code example of cyber-gh / nova-page-manager

1. Go to this page and download the library: Download cyber-gh/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/ */

    

cyber-gh / nova-page-manager example snippets


// in app/Providers/NovaServiceProvider.php

public function tools()
{
    return [
        // ...
        new \OptimistDigital\NovaPageManager\NovaPageManager
    ];
}

// Define whether the template is for a page or a region
// Applicable values: 'page', 'region'
public static $type = 'page';

// The unique name for the page, usually similar to a slug
public static $name = 'about-us';

// The package has built in SEO fields support
// This boolean decides whether or not to display them
public static $seo = false;

// If you want to have multiple views with different
// templates, you can set two templates to have the
// same 'view' string and use it instead for matching
public static $view = null;

// Return all fields here, just as you would inside a resource
public function fields(Request $request): array
{
  return [
      Text::make('Title', 'title')
  ];
}

// in /config/nova-page-manager.php

// ...
'templates' => [
  \App\Nova\Templates\HomePageTemplate::class,
],
// ...

// in /config/nova-page-manager.php

// ...
'locales' => [
  'en' => 'English',
  'et' => 'Estonian',
],

// OR

'locales' => function () {
  return Locale::all()->pluck('name', 'key');
},

// if you wish to cache the configuration, pass a reference instead:

'locales' => NovaPageManagerConfiguration::class . '::locales',
// ...

// in /config/nova-page-manager.php

// ...
'page_path' => function (Page $page) {
  return "{$page->locale}/{$page->path}";
},

// if you wish to cache the configuration, pass a reference instead:

'page_path' => NovaPageManagerConfiguration::class . '::pageUrl',
// ...

// in /config/nova-page-manager.php

// ...
'page_url' => function (Page $page) {
  return env('FRONTEND_URL') . $page->path;
},

// if you wish to cache the configuration, pass a reference instead:

'page_url' => NovaPageManagerConfiguration::class . '::pageUrl',
// ...
bash
php artisan vendor:publish --provider="OptimistDigital\NovaPageManager\ToolServiceProvider" --tag="config"
bash
php artisan pagemanager:template {className}
json
[
  {
    "locales": ["en_US", "et_EE"],
    "id": {
      "en_US": 3,
      "et_EE": 4
    },
    "name": {
      "en_US": "Home",
      "et_EE": "Kodu"
    },
    "slug": {
      "en_US": "/",
      "et_EE": "/"
    },
    "template": "home-page",
    "children": [
      {
        "locales": ["en_US"],
        "id": {
          "en_US": 5
        },
        "name": {
          "en_US": "About"
        },
        "slug": {
          "en_US": "about"
        },
        "template": "home-page"
      }
    ]
  }
]