Download the PHP package steirico/kirby-plugin-custom-add-fields without Composer

On this page you can find all versions of the php package steirico/kirby-plugin-custom-add-fields. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package kirby-plugin-custom-add-fields

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.

Installation

Use one of the alternatives below.

Download

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

Git submodule

Composer

Compatibility

Kirby Plugin
pre 3.6 1.5.0
3.6 and newer 2.0.0 and newer

Usage

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.

/blueprints/pages/remote.yml:

Reusing and Extending

The plugin supports the extends keyword for reusing and extending fields:

/blueprints/pages/event.yml:

See the kirby docs for more information on reusing and extending field.

In such a manner, kirby's default add fields (title and slug) can be reused and extended:

/blueprints/pages/book.yml:

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:

/site/models/remote.php:

If exceptions are thrown in page.create:after hooks or in hookPageCreate($page), a corresponding error is sent back to the panel, but the newly created page remains. In such cases it is advisable to catch exceptions and delete the newly created page:

Configure Redirects

Kirby's add dialog redirects to the newly created page. Since there is a related kirby issue if slugs are changed in hooks, this behavior can not be reproduced reliably. Therefore, the plugin's default behavior is to remain on the actual panel page after a page has been added.

If desired, redirect to the newly created page is possible on a per blueprint basis by setting the property redirect to true:

/blueprints/pages/parent.yml:

If redirection to an existing page after creation is required, redirect can be set to that page id.

/blueprints/pages/parent.yml:

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:

/site/config/config.php:

Skip Add Dialog

The plugin allows to skip the add dialog (see forum).

/blueprints/pages/parent.yml:

Beside setting the property skip: true one has to define the template for the new page. This can be achieved either by setting the property forcedTemplate or by the means described in Force a specific Template.

Show / hide Template Select

As of Kirby 3.5.0 the add dialog's template select is hidden if only one option is available (except in debug mode). By default, the plugin imitates this behavior in respect of the Kirby version.

Independently of the Kirby version in use, the plugins allows control/force a certain behavior by the kirby option forceTemplateSelectionField:

/site/config/config.php:

Setting the option to true will always make the add dialog show the template select. Setting it to false will hide the template select if only one template is available.

Know issues

There are some known issues related to this plugin:

License

MIT

Credits and Contributors


All versions of kirby-plugin-custom-add-fields with dependencies

PHP Build Version
Package Version
Requires getkirby/composer-installer Version ^1.1
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package steirico/kirby-plugin-custom-add-fields contains the following files

Loading the files please wait ....