TIP TopicCreatePlugin is not installed on Foswiki.org.

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

  • Since version 1.7 of this plugin, you can pass a value to a form field on the topic by adding a parameter with the same name as the field.
  • Before version 1.4 of this plugin, the extra TOPICCREATE parameters were passed in using a special parameters attribute, as follows:
       %TOPICCREATE{ template="MyTemplate" topic="%TOPIC%MyNewTopicName" parameters="MyParameterName=MyParameterValue&Hello=Goodbye" }%
    This is now deprecated. Instead, extra parameters are automatically passed through, as documented above.
  • 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
  • There is a half-baked %TOPICPATCH% implementation which requires completing, testing and documenting. You are more than welcome to implement this if you would find it useful.

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

Previous Author(s): TWiki:Main.StanleyKnutson, TWiki:Main.PeterThoeny, Foswiki:Main.PaulineCheung
Change History:  
21 Jul 2015: v1.8: Foswikitask:Item13550: Compatibilty with perl 5.22.0, add uft-8 unit tests.
09 Sep 2012: v1.7: Foswikitask:Item9367: Ability to pass values to formfields; Foswikitask:Item12071: Ability to change attachments name using TOPICATTACH; Foswikitask:Item11587: Remove calls to deprecated API's; Foswikitask:Item12020: spelling fixes -- Foswiki:Main.AndrewJones
09 Jun 2011: v1.6: Foswikitask:Item10863 - Expand macros in parameters -- Foswiki:Main.AndrewJones
06 May 2011: v1.5: No longer load preferences from plugin topic; doc updates -- Foswiki:Main.AndrewJones
08 Feb 2010: v1.4: Foswikitask:Item8281 - Changed the way extra parameters are passed using %TOPICCREATE%, so that special characters can now be passed -- Foswiki:Main.AndrewJones
08 Feb 2010: v1.3: Foswikitask:Item8480 - Fix for setting the parent; Fix for using Macros as the parent in %TOPICCREATE% -- Foswiki:Main.AndrewJones
28 Jan 2010: v1.2: Foswikitask:Item8438 - %TOPICCREATE% now allows you to define a parent for the new topic -- Foswiki:Main.AndrewJones
29 Sep 2009: v1.1: Foswikitask:Item4757 - Fixed warning when using %TOPICATTACH% -- Foswiki:Main.AndrewJones
31 Mar 2009: v1.0: Foswikitask:Item1262 - Ported to Foswiki and released as 1.0; Removed dependency on Unix utilities cp and mkdir, should now work on any OS that Foswiki does; Improved code to make it cleaner and use more of the official API; Removed deprecated API calls -- Foswiki:Main.AndrewJones
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
Dependencies: None
License: GPL (GNU General Public License)

Related Topics: DefaultPreferences, SitePreferences, Plugins

PackageForm edit

Author Foswiki:Main.AndrewJones
Version 1.9
Release 22 Jul 2015
Copyright © 2015, Foswiki Contributors; © 2009 - 2012, Andrew Jones, © 2005 - 2006, Peter Thoeny
License GPL (GNU General Public License)
Home http://foswiki.org/Extensions/TopicCreatePlugin
Support http://foswiki.org/Support/TopicCreatePlugin
Repository https://github.com/foswiki/TopicCreatePlugin
ExtensionClassification Data and Files
ExtensionType PluginPackage
Compatibility 2.0.0, 1.1.9, 1.1.8, 1.1.7, 1.1.6, 1.1.5, 1.1.4, 1.1.3, 1.1.2, 1.1.1, 1.1.0, 1.0.10, 1.0.9, 1.0.8, 1.0.7, 1.0.6, 1.0.5, 1.0.4, 1.0.2, 1.0.1, 1.0.0
ImageUrl
DemoUrl http://
SupportUrl TopicCreatePlugin
ModificationPolicy PleaseFeelFreeToModify
I Attachment Action Size Date Who Comment
TopicCreatePlugin.md5md5 TopicCreatePlugin.md5 manage 174 bytes 22 Jul 2015 - 04:15 GeorgeClark  
TopicCreatePlugin.sha1sha1 TopicCreatePlugin.sha1 manage 198 bytes 22 Jul 2015 - 04:16 GeorgeClark  
TopicCreatePlugin.tgztgz TopicCreatePlugin.tgz manage 8 K 22 Jul 2015 - 04:15 GeorgeClark  
TopicCreatePlugin.zipzip TopicCreatePlugin.zip manage 11 K 22 Jul 2015 - 04:15 GeorgeClark  
TopicCreatePlugin_installerEXT TopicCreatePlugin_installer manage 4 K 22 Jul 2015 - 04:15 GeorgeClark  
Topic revision: r3 - 22 Jul 2015, GeorgeClark
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy