This plugin extends the basic way of the Foswiki core to create webs, while circumventing some of the more arcane features that are more of a burden than useful:
WebCreatorPlugin.create.
| Parameter | Description | Default |
|---|---|---|
newweb |
name of the target web | |
parentweb |
name of the parent web which the target web is a subweb of | |
templateweb |
name of the template web | _default |
overwrite |
boolean flag to optionally override an already existing target web | off |
dry |
boolean flag to simulate web creation; if enabled no actual web is created | off |
<web-preference-name> |
WebPreference settings may be specified using all upper case parameters, such as WEBSUMMARY, ALLOWWEBVIEW, DENYWEBVIEW, SOMESETTING and the like |
|
<formfield-name> |
any additional parameter provided may be used to populate the DataForm attached to the WebHome topic. |
The %TOPIC% allows third party plugins to hook into the web creation process by registering an approriate handler.
Foswiki::Plugins::WebCreatorPlugin::registerBeforeCreateWebHandler: handlers are called before the new web is created
Foswiki::Plugins::WebCreatorPlugin::registerAfterCreateWebHandler: handlers are called after the new web has been created
$parameter hash of all settings provided to the json-rpc call.
newweb.tmpl template. The form may be extended by defining the newweb::moresettingsstep definition or
by extending the newweb::start or newweb::end definitions.
<verbatim class='tml tmplInclude'>%TMPL:INCLUDE{"newwweb"}%</verbatim>
<verbatim class='tml tmplDef'>%TMPL:DEF{"moresetingsstep"}%
<input type="hidden" name="MOREWEBPREFERENCES1" value="..." />
<input type="hidden" name="MOREWEBPREFERENCES2" value="..." />
<input type="hidden" name="MOREWEBPREFERENCES3" value="..." />
...
<input type="hidden" name="ALLOWWEBVIEW" value="..." />
<input type="hidden" name="DENYWEBVIEW" value="..." />
...
<input type="hidden" name="FormFieldName1" value="..." />
<input type="hidden" name="FormFieldName2" value="..." />
<input type="hidden" name="FormFieldName3" value="..." />
...
%END%
%TMPL:END%</verbatim>
newweb.tmpl template directly.
The basic form structure looks like this:
<form class="jqAjaxForm" action="%SCRIPTURLPATH{"jsonrpc"}%/WebCreatorPlugin/create" method="post">
*Web name*:
<input name="newweb" class="foswikiInputField required" type="text" size="60" />
*Summary*
<input type="text" class="foswikiInputField" name="WEBSUMMARY" size="60" />
*Parent web*:
<select name="parentweb" class="jqSelect2" data-width="27em" data-allow-clear="true" data-placeholder="%MAKETEXT{"none"}%" size="1">
<option></option>
%FLEXWEBLIST{
format="<option $marker>$web</option>"
marker="selected"
webs="public"
exclude="Applications.*"
separator="$n"
}%
</select>
*Template web*:
<select name="templateweb" class="jqSelect2" data-width="27em">
%FLEXWEBLIST{
format="<option $marker>$name</option>"
marker="selected"
webs="webtemplate"
include="_.*"
exclude=".*/.*"
separator="$n"
}%
</select>
<!-- additional preferences, formfield values and acls -->
<input type="hidden" name="MOREWEBPREFERENCES1" value="..." />
<input type="hidden" name="MOREWEBPREFERENCES2" value="..." />
<input type="hidden" name="MOREWEBPREFERENCES3" value="..." />
<input type="hidden" name="ALLOWWEBVIEW" value="..." />
<input type="hidden" name="DENYWEBVIEW" value="..." />
<input type="hidden" name="FormFieldName1" value="..." />
<input type="hidden" name="FormFieldName2" value="..." />
<input type="hidden" name="FormFieldName3" value="..." />
<input type="submit" class="foswikiSubmit" value="Submit" />
</form>%JQREQUIRE{"select2, ajaxform"}%
createWeb to QMPlugin so that this command can be used in workflows. That is you may create
a web as part of a transition in a web. Example:
---++ Edges
| *From* | *Action* | *To* | *Command* |
...
| approved | start project | running | createWeb("PAUTOINC001" template="_ProjectTemplate" parent="Projects") |
...
This will create P... webs under the Projects web called Projects.P001, Projects.P002, etc whenever the action "start project" is performed in the workflow passing from "approved" to "running".
Parameters are:
| Parameters | Description | Default |
|---|---|---|
"...", newweb="..." |
the target web to be created, may contain the AUTOINC which is expanded as required creating counting web names (mandatory) | |
tempalte="...", templateweb="..." |
a template web | _default |
parent="....", =parentweb="..." |
parent web, if undefined a root level web will be created | |
overwrite="on/off" |
boolean parameter letting you overwrite any existing web (use with caution) | off |
dry="on/off" |
boolean to perform a "dry" operation if activated; this is useful for testing | off |
redirect="on/off" |
boolean if enabled will redirect to the newly created web | off |
PARAMETER="value" |
any (uppercase) parameter will be stored into the target web's WebPreferences | |
<FormfieldName>="value" |
if the WebHome topic has got a form attached to it then any formfield values found in the query will be stored there |
The newly created web will have access rights ALLOWWEBVIEW, ALLOWWEBCHANGE, ALLOWWEBRENAME and ALLOWTOPICCHANGE set to the user that created the web unless specified otherwise using parameters such as in:
createWeb("PAUTOINC001"
template="_ProjectTemplate"
parent="Projects"
ALLOWWEBVIEW="ProjectsGroup"
ALLOWWEBCHANGE="ProjectsGroup")
(… line breaks added for clarity)
cd /path/to/foswiki perl tools/extension_installer <NameOfExtension> installIf you have any problems, or if the extension isn't available in
configure, then you can still install manually from the command-line. See https://foswiki.org/Support/ManuallyInstallingExtensions for more help.
| Name | Version | Description |
|---|---|---|
| Foswiki::Contrib::JQAjaxFormContrib | >=1.00 | Required |
| 16 Nov 2022 | don't hardcode defaults for web acls |
| 24 May 2022 | add command createWeb() into QMPlugin workflows |
| 05 May 2022 | add support for template webs with subwebs in it |
| 15 Oct 2020 | initial release |
| Author | Michael Daum |
| Version | 3.10 |
| Release | 30 Apr 2024 |
| Description | Flexible way to create new webs |
| Repository | https://github.com/foswiki/WebCreatorPlugin |
| Copyright | 2019-2022, Michael Daum, All Rights Reserved |
| License | GPL (GNU General Public License) |
| Home | http://foswiki.org/Extensions/WebCreatorPlugin |
| Support | http://foswiki.org/Support/WebCreatorPlugin |