Tags:
create new tag
, view all tags
Template topics (topics serving as a template when creating a new topic) currently only expand %DATE%, %WIKIUSERNAME% and %NOP%. Other variables do not get expanded. This is done by design so that it is possible to create topics containing variables.

I changed the edit script to also expand %URLPARAM{"..."}% at topic creation time. This can be used to create a generic template topic where some content gets filled in dynamically. Add this to the edit script indicated in red:

    my $foo = &TWiki::getGmDate();
    $text =~ s/%DATE%/$foo/go;
    $text =~ s/%WIKIUSERNAME%/$wikiUserName/go;
    $text =~ s/%URLPARAM{(.*?)}%/TWiki::handleUrlParam($1)/geo;  # expand URL parameters
    $text =~ s/%NOP%//go;  # Remove filler (use it to prevent search from hitting a template)

Silly example: Define a template topic containing this text:

| Favorite food:  | %URLPARAM{"food"}%  |
| Favorite drink: | %URLPARAM{"drink"}% |

Now, create a simple form with a field for a topic name (like here in Codev when creating a FeatureEnhancementRequest) and two other fields for favorite food and favorite drink. Those two fields are named "food" and "drink", respectively. When you create a new topic you pass along those named parameters, and they trigger the expansion of the embedded URLPARAMs in the template topic. This results in a new topic with a table that could look like this:

Favorite food: Sushi
Favorite drink: Sake

Change is in TWikiAlphaRelease and at TWiki.org.

-- PeterThoeny - 28 Sep 2002

In certain cirumstances it would make sense to expand other variables at the topic creation time as well. Not sure how this could be done transparently and without breaking existing template topics. One idea is to introduce a new %EXPAND{"..."}% variable that expands any variable(s) it encloses.

Related: MoreExpansionInTemplateTopic

-- PeterThoeny - 28 Sep 2002

Interesting stuff - inserted some NOPs in the code above to make it display better.

-- RichardDonkin - 30 Sep 2002

fwiw this breaks some of my existing template topics, however I think I can work around it by putting the %URLPARAM{}% that I don't want expanded at topic create into a topic all of its own that is %INCLUDE{}%ed in the template. Perhaps worth documenting how to work around this.

-- DarrylGreen - 18 Oct 2002

Or keep them in your template topic and write the variable you want to keep verbatim as %URLPARAM%NOP%{...}%. This works because %NOP% is removed when the new topic is instantiated.

Yes, this needs to be documented, hence DocsToDo. Mike?

-- PeterThoeny - 19 Oct 2002

What specifically is still needed to bring this BeijingRelease feature status up from 0% documentation?

-- GrantBow - 09 Jan 2003

Mike, we heard you were going to help out a bit but haven't seen you on twiki again yet. Hope you are doing well.

-- GrantBow - 28 Jan 2003

Edit | Attach | Watch | Print version | History: r8 < r7 < r6 < r5 < r4 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r8 - 2005-02-15 - SamHasler
 
  • 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-2017 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.