Tags:
create new tag
view all tags

SID-02174: USERNAME Variable on Template page

Status: Answered Answered TWiki version: Perl version:
Category: EditTablePlugin Server OS: Cent OS 5.2 Last update: 9 years ago

I currently have a template page created that is referenced when we want to create a new page for a new topic.

Within that template page I'm using the Editable plugin to allow users to enter data regarding that specific topic that will stamp their username automatically when the create a entry. Below is a sample of the code i'm using.

%TABLE{ sort="off" tablerules="all" tableborder="1" cellpadding="4" cellspacing="3" cellborder="1" headerrows="1"}% %EDITTABLE{ format="| select, 1, Select Branch, ALL, %FORMFIELD{"OPS Branch Code"}%, %FORMFIELD{"Sat OPS Branch Code"}%, %FORMFIELD{"Sat2 OPS Branch Code"}%, %FORMFIELD{"Sat3 OPS Branch Code"}% | text, 50 | label, 0, %USERNAME% | label, 0, %SERVERTIME{"$day $mon $year $hour:$min"}% |" changerows="on" editbutton="Click here to enter comment" }%
| *Branch Location* | *Comment* | *User* | *Date & Time Entered* |

The problem I'm having is that when the template page is called by someone creating a new topic, the %<nop>USERNAME% variable is already grabbing that users name when i only want it called whenever they use the editable. Is there a way to prevent that from happening?

-- Christopher Crowe - 2016-03-15

Discussion and Answer

See docs at TWikiTemplates - basically, write %USE%NOP%RNAME% to escape %USERNAME%. Once the template is instantiated, it will remove %NOP%.

Recommendation: Use an include="" parameter instead of the long EDITTABLE parameters. That way you can avoid the escape problem. In addition, you can centrally make changes to the EDITTABLE if needed, .e.g. no need to update all topics to change the EDITTABLE.

-- Peter Thoeny - 2016-03-16

Thanks that did the job! I had not found that doc you provided but I did run in to the NOP attribute a few times when reading. Just didn't quite grasp where to use it.

I'm very fond of the include=" ", and have been using it to build my template page for the purpose of having only one place to make changes, thanks for the advice. Most of the page is constructed using include; however, I'm still struggling with some includes such as using it with an edittable and search.

With your help earlier this year, i learned to use topic="% INCLUDINGTOPIC%" allowing me to make use of the include the way I wanted. So now i'm working to figure out how to use it with edittable and search so I can put both of those in an include. My current issue with EditTable and having it Included is that when you enter data, it wants to paste it back on the page where the code actually resides on and not on the Topic where the include=" " exists.

Would it be as simple as EDITTABLE{ format=" your attributes" changerows=" " topic="%INCLUDING TOPIC%"}?

-- Christopher Crowe - 2016-03-16

EDITTABLE{ topic="%INCLUDING TOPIC%"} would be a logical choice, but that parameter does not (yet) exist. Someone needs to enhance the plugin to do that. You could do that and contribute back the code to the community, or hire a TWiki consultant to do that for you.

-- Peter Thoeny - 2016-03-16

      Change status to:
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.
SupportForm
Status Answered
Title USERNAME Variable on Template page
SupportCategory EditTablePlugin
TWiki version

Server OS Cent OS 5.2
Web server Apache/2.0.52
Perl version

Browser & version IE 11 / Chrome 45.0.2454.101 m
Edit | Attach | Watch | Print version | History: r4 < r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r4 - 2016-03-16 - PeterThoeny
 
  • 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.