Blueprint : build vs false

Hi there

I’m having a conflit between “build” and “false” option from pages blueprint. I would like to build automatically a subpage when a page is created + hide this subpage and don’t hollow user to add or modifiy subpages. This is my blueprint, the subpage is created and I see the “Add” / “Modify” pages from the left.

    pages: false
      build:
        - title: api
          uid: api
          template: projectapi
          num: 1

I’m still running on 2.5.12, do you think this can be solved ?

Instead of using the page builder function in the blueprint, you can create those subpages with a hook, similar to what I describe in this K3 recipe, only adapted to Kirby 2 code/syntax.

Thanks, with your help, I’m close.

try {
    $newPage = $page->children()->create('api', 'projectapi', array(
        'title' => 'My API',
    ));
    echo 'The new page has been created';

} catch(Exception $e) {

    echo $e->getMessage();

}

The weird thing is I get a An unexpected error occurred when I click on “Add” (Adding subpage modal) but my subpage is created… I have removed the builder option and keep pages: false.

Hm, if you set pages: false there shouldn’t be an Add button anymore?

No, I’ve set pages:false to the subpage blueprint, to be sure the user don’t add more subpage(children children) to the subpage (children). But on the pages blueprint (parent), I have set

pages:
  template: project

Don’t know what’s in your hook, but in any case you should limit that to page with a given template. Otherwise, whenever you create any page, those subpages would be created.

Well thank you very much, it was simple as

kirby()->hook('panel.page.create', function($page) {
   $page->children()->create('api', 'projectapi', array(
        'title' => 'API',
    ));
});