Topic Create Plugin
This Plugin allows you to automatically create topics or attach files at topic save time. This is typically used by Foswiki applications to create a set of template based topics.
TOPICCREATE - Automatically Create a Set of Foswiki Topics
- The
%TOPICCREATE{}%
macro is useful for creating topics based on templates
- Example scenario: You have a notebook application where users can create new notebooks based on a notebook template topic. Each time a user creates a new notebook you would like to create a set of child topics, each based on a separate template.
- Syntax:
%TOPICCREATE{ <attributes> }%
- Attributes recognized
Attribute | Meaning | Valid input | Default |
template="" | Name of Foswiki topic to be used as template | Any valid Foswiki topic | (required) |
topic="" | Name of new Foswiki topic to create | Any valid topic name | (required) |
parent="" | Parent of the newly created topic | Any existing topic | Current topic |
disable="" | Name of the template topic containing this use of TOPICCREATE | Any valid topic name (WikiWord) | recommended |
<anything else>="" | Any other parameters are passed to a child topic to initialize any urlparams or set any form field values. | Any string | None |
- The action to create the Foswiki topic will not occur until one hits the
Save Changes
button in preview
- The
%TOPICCREATE{}%
macro will be removed upon saving of the topic
- Any attachments that are in the
template
will also be copied to the new topic
-
%TOPICCREATE%
is recursive
- Write
%TOPICCREATE{ template="MyTemplate" topic="%TOPIC%MyNewTopicName" MyParameterName="MyParameterValue" Hello="Goodbye" }%
to create a foswiki topic based on another topic MyTemplate
with the name %TOPIC%MyNewTopicName
. Any %URLPARAM{}%
or any form field values with the name MyParameterName
and Hello
present in MyTemplate
will be replaced with MyParameterValue
and Goodbye
.
- To prevent the action from happening in your template topic you should either include the
disable
argument, or escape it: %TOPICCRE%NOP%ATE{...}%
. The %NOP%
gets removed when a topic gets instantiated based on a template.
TOPICATTACH - Automatically Copy Attachments to a Topic
- Example scenario: You have a template topic and would like to attach a file whose content or name is determined by URL parameters at topic creation time. This is usually done for a topic that was just created via TOPICCREATE as described above.
- Syntax:
%TOPICATTACH{ <attributes> }%
- Attributes recognized
Attribute | Meaning | Valid input | Default |
fromtopic="" | Topic (or Web.Topic) that contains the attachment | Any valid Foswiki topic | (required) |
fromfile="" | The attachment to copy from | Any attached file from fromtopic | (required) |
disable="" | Name of the template topic containing this use of TOPICATTACH | Any valid topic name | recommended |
comment="" | Comment to appear for the attachment within this topic, replacing the comment that was in the fromtopic | a one line string | {omit parameter if no change desired} |
name="" | Name to appear for the attachment within this topic, replacing the name that was in the fromtopic | a one line string | {omit parameter if no change desired} |
- Write
%TOPICATTACH{ fromtopic="SourceTopic" fromfile="Sample.jpg" name="Snoopy.jpg" disable="..."}%
to attach Sample.jpg
from topic SourceTopic
as Snoopy.jpg
- The parameter value comment is used to change the comment (description) that shows for the topic in the table of attachments
- The "hidden" attribute of the topic is removed: the attachment can be hidden in the
fromtopic
if desired
- The
fromtopic
can specify a different web if desired. For example Foswiki.SomeTemplate
would be valid as a fromtopic
- To prevent the action from happening in your template topic you must provide the
disable
parameter with the topic name containing the %TOPICATTACH%
.
Notes
Plugin Settings
Plugin settings are stored as preferences values. You can override the defaults for these preferences in
SitePreferences, the
WebPreferences topic of the current web, or in individual topics that use the plugin.
Changing them here will have no effect! This allows you to upgrade the plugin without having to worry about losing your settings.
- Debug plugin: (See output in the Foswiki debug log)
- Set TOPICCREATEPLUGIN_DEBUG = 0
Installation Instructions
You do not need to install anything in the browser to use this extension. The following instructions are for the administrator who installs the extension on the server.
Open configure, and open the "Extensions" section. Use "Find More Extensions" to get a list of available extensions. Select "Install".
If you have any problems, or if the extension isn't available in
configure
, then you can still install manually from the command-line. See
http://foswiki.org/Support/ManuallyInstallingExtensions for more help.
Plugin Info
Related Topics: DefaultPreferences,
SitePreferences,
Plugins