Tags:
create new tag
view all tags

Question

I have a TWiki page that lists some instructions on what users have to do to set something up.. they tend to look like this:


Type the following (replacing USER with your username):

cp /user/USER/file.txt /user/USER/new_place


The 'USER' thing gets repeated a lot, and every now and then somebody forgets to replace USER on every single line, and problems occur. I would like to have the users enter their username in some way, and then have the instructions generate dynamically...

What's the best way to do this? I could use a %USER% variable, but I'm not sure how to let the user set it...

Any hints or ideas would be much appreciated.

Environment

TWiki version: TWikiRelease04x01x02
TWiki plugins: DefaultPlugin, EmptyPlugin, InterwikiPlugin
Server OS:  
Web server:  
Perl version:  
Client OS:  
Web Browser:  
Categories: Forms, Missing functionality, Documentation

-- StanSokorac - 12 Sep 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.

This is indeed possible. Basically, it works like this:

  1. In your TWiki page, have a small HTML form, with the action attribute pointing to the page itself. Writing <form action="%SCRIPTURL{view}/%WEB%/%TOPIC%"> will do for any topic, and is easier to copypaste for another use case in another topic.
  2. As input element for the form, use a simple text input field and name it, for example, user. Add other fields as you like, and don't forget a submit button.
  3. In the instructions in the same topic, type %URLPARAM{"user" default="USER"}% whereever you have USER in your instructions (see TWiki04x01.VarURLPARAM for the meaning of the parameters).

The only example I have immediately at hand is unfortunately a bit complex, but on the good side it shows the potential of the approach: TWiki.ApacheConfigGenerator accepts quite a bunch of variables and changes the contents of the textarea accordingly, for easy copypasting by the users.

-- HaraldJoerg - 13 Sep 2007

Excellent, that's exactly what I was trying to do. The "URLPARAM" part is what I was missing, I was trying to get to the field value using FORMFIELD variables, and it wasn't working.

Thanks!

-- StanSokorac - 13 Sep 2007

Change status to:
Edit | Attach | Watch | Print version | History: r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r3 - 2007-09-13 - StanSokorac
 
  • 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.