I uploaded the
TopicCreatePlugin that
PeterThoeny and I built -- it implements the capability desired at my company.
--
StanleyKnutson - 21 Nov 2005
At work we had an application where we needed to create topics based on topic templates without going through the edit/preview/save sequence, e.g. submitting an HTML form would directly create a new topic. We implemented this as a Plugin, but it is too specialized to post here.
All can be done cleanly in a Plugin, without introducing an extra script. Here is how:
- Create a form with text fields, selectors, etc. This form is used to create new topics
- The form has hidden fields:
-
name="func" value="savetopic" (magic word to trigger a topic create action)
-
name="templatetopic" value="MyTopicTemplate"
-
name="topicparent" value="MyParent"
-
name="topicname" value="MyTopic1234567"
-
name="okmessage" value="Thank you for submitting the suggestion"
- etc
- The form action points to a TopicCreateAction topic (part of the Plugin)
- It points to the
viewauth script so that the user is authenticated
- The TopicCreateAction topic has a
%TOPICCREATE{ func="%URLPARAM{func}%" }% variable
- Nothing happens if you view the TopicCreatePlugin topic in a normal manner, e.g. without any URL parameters
- The topic create action gets triggered with the magic word
func="savetopic", e.g. if the Plugin topic is "viewed" by the form action:
- The TOPICCREATE handler reads parameters from the cgi handler,
- Checks for required parameters,
- Checks if the user is authenticated,
- Checks access permissions,
- Makes sure the topic does not exist already
- If all checks are OK:
- The topic gets created
- The
%TOPICCREATE{...}% gets replaced by a "Thank you for submitting the suggestion" message
Anyone interested in implementing this nicely and posting it here on TWiki.org as a
TopicCreatePlugin?
See also
SaveContentWithoutEdit
--
PeterThoeny - 22 Nov 2003
The core code enables you to create
one topic at a time without a edit/preview/save cycle.
The proposed funtionality is pending, it is an
ImplementIdeaBeforeTheCompetition thingy. The idea is to create a set of pages at once by placing multiple
%TOPICCREATE{ }% in a
template topic. Needed by
TWikiApplications. At work we implemented this in a company specific Plugin. Useful.
--
PeterThoeny - 02 Nov 2004
So for example you could create a plugin topic, it's Dev topic, and
PluginAppraisal topic with one click?
--
SamHasler - 02 Nov 2004
Yes, that is the idea
--
PeterThoeny - 03 Nov 2004
yes, this is definitely needed for
TWikiApplications. a plugin that i've recently created (which will be posted at
TWiki:Plugins.NewPageEventPlugin
when ready) is similiar to this; see also
Bugs:Item1014
.
--
WillNorris - 21 Nov 2005
Stanley just packaged and uploaded the Plugin. Thanks Stanley! Enjoy.
--
PeterThoeny - 21 Nov 2005
i've added the plugin to
SVN:7585
--
WillNorris - 21 Nov 2005
Suggested enhancements:
- Finish disabled/undocumented
%TOPICPATCH{}% feature
- Replace external Unix calls with native Perl functions (Bugs:Item1016
)
--
PeterThoeny - 21 Nov 2005
I think
WillNorris is suggesting an important enhancement: have a form that creates multiple topics directly, without need of an extra 'save' step as needed by
TopicCreatePlugin.
This would solve an important usability issue with
TopicCreatePlugin: the "save" operation is currently require, and the user sees the cryptic TOPICCREATE items listed. This would scare away non-techy users.
--
StanleyKnutson - 22 Nov 2005
Thank you so much for this plugin! I've been trying to figure out a way to do this for months.
I've begun to work with it immediately and have found one small bug (
Bugs:Item1030
).
--
LynnwoodBrown - 23 Nov 2005
This doesn't seem to be packaged right, as it installed stuff directly into my /twiki directory
--
MeredithLesly - 25 Feb 2006
Very useful plugin. Would be nice if we could define the parent of the new topic. May have a go at implementing this myself if I get some free time (think it said
FeelFreeToModify).
I also found that it installed stuff into my /twiki directory.
--
AndrewRJones - 25 Oct 2006
Packaging: Indeed, the zip file had old files in the pakage root. Fixed & re-uploaded.
Setting parent of topic: I am not sure if this works, but try
parameters="topicparent=FooBar"
--
PeterThoeny - 25 Oct 2006
Tried
parameters="topicparent=FooBar" but it has no effect.
Also the plugin does not recognise %STARTSECTION{type="templateonly"}%, but its only a Nice To Have.
--
AndrewRJones - 26 Oct 2006
I have also observed that it does not respect the use of
%NOP% which I have used to prevent a variable from expanding when the topic is created. This is useful for defining a template of a template topic. TopicCreatePlugin goes ahead and removes the NOP
and expands the surrounding variable.
--
LynnwoodBrown - 26 Oct 2006
I got around to updating the archives attached to the plugin topic since several fixes had already been checked into svn. (In particular
Bugs:Item1030
which had created problems for
TopicClassificationAddOn).
--
LynnwoodBrown - 23 Feb 2007
Thanks Lynnwood for updating the plugin!
--
PeterThoeny - 23 Feb 2007
I just installed this Plugin an my Twiki 4.12. When I try to create an new topic, the Plugin creates the files for the new Topic, but adds a newlinecharacter at the end of the filename => the new Topic is broken. I debugged the error and found out that TWiki::Func::expandCommonVariables() in line 83 in the file Func.pm adds this newline to $topicName and causes this error. I did not have the time to find the real reason, therefore I used the commented workaround I found some lines below. Maybe somebody can fix this ...
--
WolfgangBertl - 11 Nov 2007
I got this feedback via e-mail from
MartinFranz:
recursive topic creation does not work due a bug in sub handleTopicCreate
Quite at the end of the function I had to replace:
# Recursively handle TOPICCREATE and TOPICATTCH
#$text =~ s/%RED% Error in %<nop>TOPICCREATE{(.*)}%: Parameter =templatete= is missing or empty. %ENDCOLOR% [\n\r]*/handleTopicCreate( $1, $topicName )/geo;
$text =~ s/%RED% Error in %<nop>TOPICCREATE{(.*)}%: Parameter =templatete= is missing or empty. %ENDCOLOR% [\n\r]*/handleTopicCreate( $1, $theWeb, $topicName )/geo; # FRM Patch
#$text =~ s/%TOPICATTCH{(.*)}%[\n\r]*/handleTopicAttach( $1, $topicName )/geo;
$text =~ s/%TOPICATTCH{(.*)}%[\n\r]*/handleTopicAttach( $1, $theWeb, $topicName )/geo; # FRM Patch
The second parameter is expected to be the WEB.
--
PeterThoeny - 16 Mar 2008
Like Andrew commented above, I couldn't get the 'parameters' option to work with this plugin. Has anyone?
--
HelenJohnstone - 14 May 2008
I too am not having any luck getting the parameters option to work. Any new development on this? I am specifically attempting to transfer % URL{topicparent} %
--
XochipalaValdez - 2009-05-06
Updated version posted using
TWikibug:Item7586
:
- Expand variables on topic creation
- Create new topics across webs
- New parent parameter
- General code cleanup
Thank you Alba Power Quality Solutions for sponsoring this work!
--
Peter Thoeny - 2014-11-07