Hello,
I’m using @texnixe’s TreeBuilder plugin in order to automatically create a subpage for my pages.
I need this page to be created when the page is updated; so I used this in my config file:
'page.update:after' => function ($newPage) {
if ($newPage->children()->isEmpty()) {
buildPageTree($newPage);
}
}
I’m already having subpages created manually for those pages, so this hook doesn’t work if there are subpages already on the page.
Can I make it so it updates if there’s no automatically generated page created but ignore the rest? Something like if ($newPage->children($autopage)->isEmpty())
Thanks for the reply.
Truth is I don’t know the slugs. I have a pages field where the user can create their own pages.
Would it be possible to do the same but by excluding the ‘template’, for example?