I’m building a site where the client will be able to create Landing Pages at will. Each Landing Page is made up of:
- a Hero Banner section
- (optional) Information Sections
- a Contact Section
So, the Hero and the Contact sections are compulsory: every page must have one. The Information Sections are optional, and the client may create a Landing page with none, and another with several. I’ve set this up as a ‘one-pager’: the Landing Page is the parent, and the sections are child pages.
As suggested by @texnixe in another post, I followed the migration docs - “Remove Blueprint-based subpage builder” section - to create a
page.create:after hook, so the Landing Page auto-creates the Hero Banner and the Contact Section when it’s created. But, I’m finding that this solution has a couple of issues I’m not being able to work through.
First, I’d like these sections to always show up in the parent page with a ‘listed’ status. The hook is supposed to automatically add a sorting num on the pages when it creates them, but it can only do that IF the pages have
changeStatus set to true. This means, unfortunately, that the user will be able to change the status as well, which I don’t want to allow.
Second, I also don’t want to allow the user to delete these 2 sections - they should always be present on the Landing Page. So, I set the
delete: option in their blueprints to false. This, however, stops the parent Landing Page from being deleted altogether, because when it tries to delete its children, it can’t, and so the whole delete operation fails. I’ve tried setting up a
page.delete:before hook, but cannot seem to be able to delete the subpages programatically while their
delete is set to false - even if trying to force-delete using
What is the proper way to do this? Is there a way to override these page options programatically? Any guidance is most welcome.