Rrr
1
Hey there,
Not sure if possible, so decided to ask here.
This is for the subpages in a parent page.
What I am trying to do is limit the user ability to create only 1 calendar page within the parent.
pages:
sort: flip
hide: true
max: 5
template:
- calendar
- custompage
The result I’m looking for is 1x Calendar subpage and 1-4 Custom Pages.
Any ideas?
Thanks in advance!
This can be achieved with role based Panel permissions: https://getkirby.com/docs/panel/permissions
In your example that would be something like:
<?php
// site/roles/editor.php
return [
'name' => 'Editor',
'default' => true,
'permissions' => [
'*' => true,
'panel.page.create' => function() {
if($this->target()->page()->intendedTemplate() == 'parent_template'
&& (($this->target()->page()->children()->filterBy('template', 'calendar')->count() >= 1 && $this->target()->blueprint() == 'calendar')
|| ($this->target()->page()->children()->filterBy('template', 'custompage')->count() >= 4 && $this->target()->blueprint() == 'custompage'))) {
return false;
} else {
return true;
}
}
]
];
1 Like