Skip to content
Custom fields for Kirby's add dialog.
Branch: master
Clone or download
Latest commit 65764a1 Apr 27, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
vendor Fix incorrect redirect Apr 26, 2019
.editorconfig Update documentation and plugin properties Apr 22, 2019
.gitignore Update documentation and plugin properties Apr 22, 2019 Update documentation and plugin properties Apr 22, 2019 Add feature forcedTemplate Apr 27, 2019
composer.json Update to v1.1.0 Apr 27, 2019
composer.lock Fix incorrect redirect Apr 26, 2019
config.php Add feature forcedTemplate Apr 27, 2019
index.js Fix incorrect redirect Apr 26, 2019
index.php Update documentation and plugin properties Apr 22, 2019

Kirby custom Add Fields Plugin

Custom fields for Kirby's add dialog. This plugin allows to define the fields shown on Kirby's page add dialog in the corresponding page's blueprint.



Use one of the alternatives below.


Download and copy this repository to /site/plugins/kirby-plugin-custom-add-fields.

Git submodule

git submodule add site/plugins/kirby-plugin-custom-add-fields


composer require steirico/kirby-plugin-custom-add-fields


Defining custom Add Fields

This plugin adds the extra property addFields to page blueprints. To define custom add fields do as you would do for defining regular fields but put the definition in the property addFields.


title: Blueprint with custom Add Fields

    # field definitions
        label: Title
        type: text
        label: Content
        type: textarea

# custom add fields definition
        label: Title
        type: text
        required: true
        icon: title

        label: URL to external Content
        type: select
            '': Lorem Markdownum
            '': README
        icon: url

Using custom Add Fields

Values of custom add fields that correspond to fields of the page blueprint are taken into account for the new page straightforwardly. In the example above the value of title in the add page dialog will be set as page's title.

slug Handling

In order to have kirby adding pages correctly the property slug has to be set. There are three ways to define a page's slug:

  1. Add a custom add field named slug in order to define the slug manually.
  2. If a field named slug is missing the plugin will set the slug based on the current timestamp.
  3. Set/overwrite the slug in a pages hook script (see below).

Using custom Add Fields in Hook Scripts

The values of the custom add fields can be used on the server side for modifying the page to be added.

To do so one can register a page.create:after hook and modify the page object.

The plugin also registers a generic hook which automatically detects and calls the page model's static method named hookPageCreate($page). Define a page model and the method as follow:


class RemotePage extends Page {
    public static function hookPageCreate($page){
        // get value of add field remoteUrl
        $remoteUrl = $page->remoteUrl()->value();

        // fetch remote content
        $content = file_get_contents($remoteUrl);

        // update page field content
            'content' => $content

        // set slug according to add field title

Force a specific Template

The template to be used for the new page can be forced by a field of the current page. By default, if a field called forcedTemplate exists on the current page its value is taken into account as template for the new page.

The field can be changed by kirby options:



return [
    // exitsing configurations
    'steirico.kirby-plugin-custom-add-fields.forcedTemplate.fieldName' => 'myForcedTemplateField'

Know issues

There are some known issues related to this plugin:

  • Fields such as the pages field perform additional requests to the backend. Such fields may not work with this plugin. Feel free to file an issue if you encounter a broken field.
  • Conditional fields are untested.
  • Kirby offers no possibility to redirect to the newly created page if the slug has been modified in a hook. Therefore, after adding a page the panel remains on the actual page.




You can’t perform that action at this time.