This Plugin allows you to automatically create topics or attach files at topic save time. This is typically used by TWiki applications to create a set of template based topics.
TOPICCREATE - Automatically Create a Set of TWiki Topics
The %TOPICCREATE{}% TWikiVariable 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.
Name of the template topic containing this use of TOPICCREATE
Any valid topic name (WikiWord)
recommended
parameters=""
List of parameters to pass to a child topic to initialize any urlparams.
Following syntax: <parameter-name>=<parameter-value> followed by any number of parameter name, value pairs separated by &
No Parameters
The action to create the TWiki topic will not occur until one hits the Save Changes button in preview
The %TOPICCREATE{}% variable 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" parameters="MyParameterName=MyParameterValue&Hello=Goodbye" }% to create a twiki topic based on another topic MyTemplate with the name %TOPIC%MyNewTopicName. Any %URLPARAM{}% 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's 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.
Name of the template topic containing this use of TOPICATTACH
Any valid topic name (WikiWord)
(required)
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}
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 TWiki.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%.
Limitations/TODO:
There should be a name argument to rename the topic as it is copied
The TOPICATTACH must be in the 'top level' topic being saved by a TOPICCREATE. It can not be in a recursive/subordinate topic invoked by the TOPICCREATE.
Plugin Settings
Plugin settings are stored as preferences variables. To reference a plugin setting write %<plugin>_<setting>%, i.e. %TOPICCREATEPLUGIN_SHORTDESCRIPTION%
Set SHORTDESCRIPTION = Automatically create a set of topics and attachments at topic save time
Debug plugin: (See output in data/debug.txt)
Set DEBUG = 0
Known issues
This Plugin is Unix specific and depends on the Unix utilities cp and mkdir.
For safety reasons, the path to the utilities is hardcoded in the Plugin module. The path might need to be changed depending on your environment.
Precautions have been taken to make this Plugin safe. It does not have ANY WARRANTY, does not even have the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. It is up to the administrator to decide if this Plugin is safe for a public TWiki site.
Plugin Installation Instructions
Note: You do not need to install anything on the browser to use this plugin. The following instructions are for the administrator who installs the plugin on the server where TWiki is running.
Download the ZIP file from the Plugin web (see below)
Unzip TopicCreatePlugin.zip in your twiki installation directory. Content: