Call subpage builder not just in Panel

Is there any way to call the panels subpage builder in my template code? Is that function hardcoded to the panel?

What are you trying to achieve? The subpage builder uses the Kirby $pages->create() method to create the subpages.

i need a frontend button that works like the new page button in the panel.

unless i miss something… but when i call create in my template code the subpagebuilder is not invoked. so there is a difference from pressing the new page button in the panel and creating a new page by code.

Well, the Panel takes it’s information from the blueprint when creating a new file. The frontend, of course, knows nothing of the blueprints. You would have to read the blueprints to simulate the behavior of the Panel (if you want to do that, maybe Kirby Architect can help to achieve that).

Or you would have to tell your button what to create explicitly.

Here is what happens in the Panel:

  public function create($uid, $template, $content = array()) {

    if(empty($template)) {
      throw new Exception(l('pages.add.error.template'));

    $uid       = empty($uid) ? str::random(32) : $uid;
    $blueprint = new Blueprint($template);
    $data      = array();

    foreach($blueprint->fields(null) as $key => $field) {
      $data[$key] = $field->default();

    $data  = array_merge($data, $content);
    $event = $this->page->event('create:action', [
      'parent'    => $this->page,
      'template'  => $template,
      'blueprint' => $blueprint,
      'uid'       => $uid,
      'data'      => $data      


    // create the new page and convert it to a page model
    $page = new Page($this->page, parent::create($uid, $template, $data)->dirname());

    if(!$page) {
      throw new Exception(l('pages.add.error.create'));

    kirby()->trigger($event, $page);

    // subpage builder
    foreach((array)$page->blueprint()->pages()->build() as $build) {
      $missing = a::missing($build, array('title', 'template', 'uid'));
      if(!empty($missing)) continue;
      $subpage = $page->children()->create($build['uid'], $build['template'], array('title' => $build['title']));
      if(isset($build['num'])) $subpage->sort($build['num']);

    return $page;



ah i see. blueprints and the subpagebuilder are just a part of the panel not the kirby core. i will create my own recursive function then. thanks.