I have a default page blueprint, which allows child pages to be created from it which again use the default template. Is it possible to somehow limit the ‘depth’ of pages that can be created? For instance if I didn’t want pages to be created deeper than 3 levels.
I’d love to know the answer to this, too.
You could do things like have section blueprints allow for suppages, but then the subpage/child blueprint NOT allow children by simply removing the pages fields.
Just out of curiosity, why are are you against going deeper then three levels?
On a side note, i think you can use the router built in to kirby so that altough in the file system the pages are nested deeper but in terms of the url in the browser, they only 2 or 3 levels deep.
Basically this… The power of routes | Kirby CMS
Perhaps that works for you.
Unfortunately, it’s not possible to use query language to set a value for page blueprint options, otherwise it would be easy.
For this setup, I guess you would have to create a page model. In this page model, overwrite the rules method to return a custom PageRules class with your own rules.
A simpler alternative would be a hook that rejects page creation when, but then only when the user submits the dialog.
Could become a problem with many pages deeply nested, because you cannot prevent user from creating pages with the same slug. When they are virtually on the same level as existing pages on that level, this would basically render them inaccessible.
Ah yeah, thats true. good point!
@texnixe would it be possible in a plugin to warn a user in the panel if they have created a page with the same slug as another page?
Yes, via a hook you could throw an error.
But I think it would be better to prevent unlimited nested pages right from the beginning. Before I start fighting against this with routes, an error via hook would be the better approach.
Or simply create different blueprints, then you don’t have the problem at all.
I think thats actually the crux of all this. Personally i always create distinct templates. For me the default template is a last resort fallback, its not something i actively drive pages with.
I thought hooks were disconected from popping dialogues in the panel (like those are on the PHP side rather than being able to talk to the Vue/Panel side). Maybe i missed something there.
You cannot redirect anywhere, but you can throw an error, that is then shown in the Panel.
Hi all,
Thanks for all the responses!
My query came about as I was setting up an online catalogue for site, and I was creating different blueprints purely to restrict the levels they were on (“Section” blueprint where the user can create “Subsection” or “Item” pages, “Subsection” blueprint where the user can create “Sub-subsection” or “Item” pages, and a “Sub-subsection” blueprint from which they can only create “Item” pages). It seemed a bit convoluted so I was wondering if I could impose a limit in another, perhaps simpler way.
From looking through the replies it seems that I can’t, which is totally fine. Thanks again everyone for taking the time to respond.