create new tag
, view all tags

Feature Proposal: add a settingstopic parameter to edit&save


Similar to templatetopic and formtemplate, but used to over-ride the META:PREFERENCES of the target topic.

Description and Documentation

Some templates already have a SETTINGSTEMPLATE html form input, but it is not actually used - this proposal would enable us to over-ride the settings in a topic.

I would also like to add some way to set PREFERENCES from the save and edit URL, in a similar fashion to formfields - though this may need to be done via special prefixes - eg save/Web/Topic?prefBANANA=yes would set BANANA=yes

would also need to differentiate between setting the variable to and empty string, and unsetting it entirely - eg save/Web/Topic?unset=BANANANA

an alternative I'm exploring would use QuerySearch like statements, allowing (or attempting to) a single save to modify several topics

   * ?setSandbox.TestTopic5/preferences[EditDocumentState]=SomeValue
   * ?setSandbox.TestTopic5/fields[EditDocumentState]=SomeValue



WhatDoesItAffect: API, Documentation, Prefs, Usability, Vars


frighteningly simple:
    TWiki::Func::writeDebug( "- ${pluginName}::beforeSaveHandler( $_[2].$_[1] )" ) if $debug;
    my $cgi = TWiki::Func::getCgiQuery();
    my $settingsTopic = $cgi->param('settingstopic');
    if (defined($settingsTopic)) {
        my ($sWeb, $sTopic) = TWiki::Func::normalizeWebTopicName($_[2], $settingsTopic);
        if (TWiki::Func::topicExists($sWeb, $sTopic)) {
            my( $sMeta, $sText ) = TWiki::Func::readTopic($sWeb, $sTopic);
            $_[3]->copyFrom( $sMeta, 'PREFERENCE' );
    my $unset = $cgi->param('unset');
    if (defined($unset)) {
        my @uS = split(/\s*,\s*/, $unset);
        foreach my $s (@uS) {
            $_[3]->remove('PREFERENCE', $s );
(cept in the process I think I found a bug.)

as you can see I'm actually implementing this as a plugin, I do need it now :), but to work properly, it will require the edit and preview screens to pass on the settingstopic, unset and prefBANANA values.

-- Contributors: SvenDowideit - 23 May 2008


Setting topic preferences on a save would be great. It is currently done via manage. Can we remove setprefs from manage?

-- MichaelDaum - 23 May 2008

Sensible enhancement. i think we need to spend some more brain cycles on an intuitive syntax for the parameters.

-- PeterThoeny - 23 May 2008

Any implications we need to think about with respect to XSS?

If someone can send an email with a URL with a save, will this enhancement make something more vulnerable? I am not saying it will. But it was one of my first thoughts.

-- KennethLavrsen - 27 May 2008

yes, there are issues wrt XSS - not just for this proposal, but for all the existing functionality that the save script provides - so its not opening up anything new frown

I'll have to contemplate a SecureTWikiFromXSS

-- SvenDowideit - 28 May 2008

On syntax, ?Set+LUNCH=Sushi would be pretty much aligned with the Set LUNCH = Sushi syntax we are familiar with.

What if these parameters are set in edit, should they be passed along to preview and save?

-- PeterThoeny - 28 May 2008

mm, its better than my syntax - i will try it out later.

I also am thinking of adding a texttopic param that will alow you to point to a topic who's content can be used to set the text to be saved - similar to how topictemplate works on topic creation. I investigated just changing topictemplate to do it, but there are too many side effects from it, as it gets involved in formfields, topic parent and so on.

Safer to have seperate url params for the seperate topic components (which could all point to the same source topic).

-- SvenDowideit - 13 Jun 2008

From Bugs:Item5701

I vaguely remember asking for clarification on this one, because I couldn't understand why on earth you would ever want it to work the way it did. To me, templatetopic means "a topic to be used as a template when creating a new topic", rather than "a means to blow away any text parameter you might pass to the save". I agree with your conclusions, though long term I might have preferred to see a mechnanism by which I could template any part of a topic that is indexable under the terms of the QuerySearch syntax.

-- SvenDowideit - 25 Jun 2008

Edit | Attach | Watch | Print version | History: r10 < r9 < r8 < r7 < r6 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r10 - 2008-06-25 - SvenDowideit
  • 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-2018 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.