admin_tool1Add my vote for this tag automation1Add my vote for this tag component2Add my vote for this tag editing2Add my vote for this tag productivity2Add my vote for this tag twiki_application3Add my vote for this tag create new tag
, view all tags

Topic Create Plugin

This Plugin allows you to automatically create new topics or attach files at topic save time. This is typically used by TWiki applications to create a set of topics based on different templates.

- 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 children topics, each based on a different template.
  • Syntax: %TOPICCREATE{ <attributes> }%
  • Attributes recognized:
    Attribute Meaning Valid input Default
    template="" Name of TWiki topic to be used as template Any valid TWiki topic (required)
    topic="" Name of new TWiki topic to create Any valid WikiWord (required)
    parent="" Name of parent topic Any valid WikiWord (parent of template topic)
    disable="" 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 & or ;
    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 over 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.

- 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.
  • Syntax: %TOPICATTACH{ <attributes> }%
  • Attributes recognized:
    Attribute Meaning Valid input Default
    fromtopic="" Topic (or Web.Topic) that contains the attachment Any valid TWiki 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 (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%.

Known issues & limitations

  • 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.
  • 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.

  • Run configure to install the plugin, then enable the plugin in configure.
  • Alternatively, download the ZIP file from the Plugin web (see below) and install the plugin manually:
  • Unzip TopicCreatePlugin.zip in your twiki installation directory. Content:
    File: Description:
    data/TWiki/TopicCreatePlugin.txt Plugin topic
    lib/TWiki/Plugins/TopicCreatePlugin.pm Plugin Perl module
    lib/TWiki/Plugins/TopicCreatePlugin/Func.pm Plugin core functionality
  • Test if the installation was successful:
    • Create a test topic called TestTopicCreate with this content:
      %TOPICCREATE{ template="TWiki06x00.WikiWord" topic="%TOPIC%Child" }%
    • After saving TestTopicCreate you should get a new topic TestTopicCreateChild with the content of WikiWord.

Plugin Info

  • One line description, is shown in the TextFormattingRules topic:
    • Set SHORTDESCRIPTION = Automatically create a set of topics and attachments at topic save time

Plugin Author: TWiki:Main.StanleyKnutson, TWiki:Main.PeterThoeny, TWiki:Main.PaulineCheung, TWiki:Main.AndrewRJones
Copyright: © 2005-2014 Peter Thoeny;
© 2009 Andrew Jones;
© 2008-2014 TWiki:TWiki.TWikiContributor
License: GPL (GNU General Public License)
Sponsor: Alba Power Quality Solutions for 2014-11-07 version
Plugin Version: 2014-11-07
Change History:  
2014-11-07: TWikibug:Item7586: Expand variables on topic creation; create new topics across webs; new parent parameter; code cleanup
2011-07-13: TWikibug:Item6725: Change global package variables from "use vars" to "our"
25 Oct 2009: TWikibug:Item6357 - removed dependency on Unix utilities cp and mkdir, should now work on any OS that TWiki does; removed depreciated API calls -- TWiki:Main.AndrewRJones
11686 TWikibug:Item2956 - freeze TWikiRelease04x00 and copy it to new branch MAIN
10613 TWikibug:Item2473 - files in pub and data directories shouldn't be marked executable in svn (Ordnung muss sein)
7960 TWikibug:Item1238 - plugins cleanup: added BuildContrib support/infrastructure
7585 TWikibug:Item1016 - initial import of TopicCreatePlugin (thanks TWiki:Main.StanleyKnutson and others)
21 Nov 2005: Initial TOPICCATTACH
30 Apr 2005: Initial version
TWiki Dependency: $TWiki::Plugins::VERSION 1.2
CPAN Dependencies: none
Other Dependencies: none
Perl Version: 5.008
Plugin Benchmark: GoodStyle nn%, FormattedSearch nn%, TopicCreatePlugin nn%
Plugin Home: http://TWiki.org/cgi-bin/view/Plugins/TopicCreatePlugin
Feedback: http://TWiki.org/cgi-bin/view/Plugins/TopicCreatePluginDev
Appraisal: http://TWiki.org/cgi-bin/view/Plugins/TopicCreatePluginAppraisal

Related Topics: TWikiPreferences, TWikiPlugins

Topic attachments
I Attachment History Action Size Date Who Comment
Unknown file formatmd5 TopicCreatePlugin.md5 r12 r11 r10 r9 r8 manage 0.2 K 2014-11-08 - 00:27 PeterThoeny  
Compressed Zip archivetgz TopicCreatePlugin.tgz r13 r12 r11 r10 r9 manage 8.4 K 2014-11-08 - 00:27 PeterThoeny  
Compressed Zip archivezip TopicCreatePlugin.zip r14 r13 r12 r11 r10 manage 11.3 K 2014-11-08 - 00:27 PeterThoeny  
Compressed Zip archivetgz TopicCreatePluginTest.tgz r1 manage 8.6 K 2005-11-21 - 21:56 StanleyKnutson Sandbox test case for TopicCreatePlugin
Unknown file formatEXT TopicCreatePlugin_installer r4 r3 r2 r1 manage 3.5 K 2014-11-08 - 00:27 PeterThoeny  
Edit | Attach | Watch | Print version | History: r17 < r16 < r15 < r14 < r13 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r17 - 2014-11-08 - PeterThoeny
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2015 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.