panel.page.create

Permission to create a new page

Target Data

ui

$this->target()->page()

action

$this->target()->page()
$this->target()->template()
$this->target()->blueprint()
$this->target()->uid()
$this->target()->data()

Example

<?php

// site/roles/editor.php
return [
  'name'        => 'Editor',
  'default'     => false,
  'permissions' => [
    '*'                 => true,
    'panel.page.create' => false
  ]
];

Allow new pages based on the parent template

// site/roles/editor.php
return [
  'name'        => 'Editor',
  'default'     => false,
  'permissions' => [
    '*'                 => true,
    'panel.page.create' => function() {
      return $this->target()->page()->template() === 'projects';
    }
  ]
];

Only allow a certain pages with a specific UID

// site/roles/editor.php
return [
  'name'        => 'Editor',
  'default'     => false,
  'permissions' => [
    '*'                 => true,
    'panel.page.create' => function() {

      if($this->state() === 'ui') {
        // always show the add button
        return true;
      }

      if($this->target()->uid() !== 'something-really-specific') {
        return 'You are only allowed to add pages with a very specific URL appendix';
      }

      return true;

    }
  ]
];

Only allow adding pages in a certain language

// site/roles/editor.php
return [
  'name'        => 'German Editor',
  'default'     => false,
  'permissions' => [
    '*'                 => true,
    'panel.page.create' => function() {
      return $this->language()->code() === 'de';
    }
  ]
];