====== Newpagefill Plugin ======

---- plugin ----
description: Page creation helper with prefill and @TITLE@ support
author     : Valentin LORTET
email      : contact@valentinlortet.fr
type       : Action
lastupdate : 2026-03-13
compatible : Librarian
depends    :
conflicts  :
similar    :
tags       : Page, Creation, Template, Namespace, JavaScript

downloadurl: https://github.com/Lortet/dokuwiki-plugin-newpagefill/zipball/master
bugtracker : https://github.com/Lortet/dokuwiki-plugin-newpagefill/issues
sourcerepo : https://github.com/Lortet/dokuwiki-plugin-newpagefill/
donationurl:
screenshot_img :
----

[[fr:plugin:newpagefill|🇫🇷 Français]] | 🇬🇧 **English** | [[de:plugin:newpagefill|🇩🇪 Deutsch]] | [[es:plugin:newpagefill|🇪🇸 Español]]

===== Installation =====

Install the plugin from the [[plugin:extension|Extension Manager]].

===== Description =====

The **newpagefill** plugin adds a lightweight helper to create a new page:
  * enter a title;
  * automatically suggest a page ID;
  * optionally enter the namespace;
  * choose the creation mode depending on configuration;
  * open the editor directly on the target page.

It also complements the native DokuWiki template system:
  * use ''_template.txt'' or ''%%__template.txt%%'' when available;
  * add support for the ''@TITLE@'' placeholder in the injected content;
  * fall back to a plugin-specific template when no native template exists.

===== Settings =====

^ Name ^ Description ^ Default value ^
| template | Fallback template used when no native DokuWiki page template is found. | ''===== @TITLE@ ====='' |
| default_start_mode | Default creation mode. | ''start'' |

Possible values for ''default_start_mode'':
  * ''ask'': show a selector in the dialog;
  * ''start'': create a start page;
  * ''none'': create a direct page;
  * ''same'': create a subpage with the same name.

===== Placeholders =====

The plugin template may contain:
  * ''@TITLE@'': title computed by the plugin (specific to newpagefill);
  * all native DokuWiki placeholders: ''@ID@'', ''@NS@'', ''@PAGE@'', ''@USER@'', ''@DATE@'', etc. (handled by DokuWiki core, not by this plugin).

===== @TITLE@ behaviour =====

The value of ''@TITLE@'' is computed as follows:
  * the request ''title'' value has priority;
  * otherwise, the plugin tries to extract a title from the creation URL;
  * if the created page is the namespace start page, the parent namespace name is used;
  * ''_'' characters are replaced with spaces.

===== Template compatibility =====

The plugin follows this order:
  * template already provided by DokuWiki;
  * ''_template.txt'' in the target folder;
  * %%__template.txt%% in the current or parent namespace;
  * fallback template configured in the plugin.

===== JavaScript function =====

The plugin exposes the global function:

<code javascript>
window.NewPageFill.openCreatePageDialog(options)
</code>

Example:

<code javascript>
window.NewPageFill.openCreatePageDialog({
  namespace: 'wiki:documentation',
  initialTitle: 'New page'
});
</code>

Useful options:
  * ''namespace'': target DokuWiki namespace;
  * ''initialTitle'': prefilled title;
  * ''start'':
    * ''undefined'' or ''null'': use the plugin configuration;
    * ''@ask@'': force the mode choice dialog;
    * ''true'': use the wiki start page;
    * ''false'': create the page directly;
    * ''@same@'': create a subpage with the same name as the page ID;
    * any other string: create a subpage with that value;
  * ''sepchar'': separator used to generate the page ID.

If ''start'' is not provided and ''default_start_mode = ask'', the dialog offers:
  * direct page;
  * start page;
  * subpage with the same name.
