Tags:
create new tag
view all tags

Question

  • One of my webs contains several categories like "Abbreviation" or "Documents".
  • I have created several templates within a web, one for each category.
  • Depending on the category, I want to preselect the corresponding template in WebTopicCreator in order to make it easier for the user.
  • I know that I can provide special parameters to WebTopicCreator (at the moment it is only "parent").
  • I want to give a parameter called topictemplate to WebTopicCreator.
  • My question is: How can I change the code in WebTopicCreator in order to preselect the appropriate template within the selection box (the preselected one is "Default template" at the moment)?

Environment

TWiki version: TWikiRelease04x01x02
TWiki plugins: DefaultPlugin, EmptyPlugin, InterwikiPlugin
Server OS: RedHat
Web server: Apache
Perl version: 5.8
Client OS: Windows XP Service Pack2
Web Browser: Internet Explorer, Firefox
Categories: Missing functionality

-- KirstinWeber - 31 May 2007

Answer

ALERT! If you answer a question - or someone answered one of your questions - please remember to edit the page and set the status to answered. The status selector is below the edit box.

Good suggestion to add a template parameter. Just after

<select name="templatetopic" class="twikiSelect">
add this line:
%IF{"$templatetopic" then='<option value="%URLPARAM{templatetopic}%" selected="selected"></option>'}%

-- ArthurClemens - 31 May 2007

I tried it but it does not work. So I tried

<p>%STARTSECTION{"topictemplate"}%<select name="templatetopic"> <option value="">%MAKETEXT{"Default template"}%</option>%SEARCH{".*Template$" scope="topic" type="regex" nonoise="on" format="<option %IF{"$topictemplate=$topic" then=selected="selected"}%>$topic</option>"}%</select> <a href="%SCRIPTURL{view}%/TWiki06x01/WebTemplateTopics?web=%BASEWEB%">View templates</a> %ENDSECTION{"topictemplate"}%</p>

But it does not work either. I think the compare is wrong because if I do not compare templatetopic with $topic the last template of the selection is shown. But I do not know how to change the compare to be correct.

-- KirstinWeber - 01 Jun 2007

You need to escape the IF in the format so that it evaluates once per hit, and not just once per search:

format="<option $percntIF{\"$topictemplate=$topic\" then='selected=\"selected\"'}$percnt>$topic</option>"

-- PeterThoeny - 29 Jul 2007

Thanks. I replaced $topictemplate by %URLPARAM{topictemplate}% because I want to check the given parameter. Now it works but only if the parameter is given. Otherwise the comparision is not correct because %URLPARAM{topictemplate}% is empty. How can I manage the case if %URLPARAM{topictemplate}% is not given?

-- KirstinWeber - 31 Jul 2007

See TWiki.VarURLPARAM for a description of URLPARAM's default attribute, where you can give, well, a default value in case parameter is empty or missing.

-- HaraldJoerg - 31 Jul 2007

Great! Now it is working. I had some problems with using quotation marks but now it is working. Thanks to all of you for your help!

-- KirstinWeber - 01 Aug 2007

Change status to:
Edit | Attach | Watch | Print version | History: r8 < r7 < r6 < r5 < r4 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r8 - 2007-08-01 - KirstinWeber
 
  • 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-2026 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.