Tags:
create new tag
view all tags

SID-00097: How to pass a TWiki variable into a link

Status: Answered Answered TWiki version: 4.0.5 Perl version: 5.6.0
Category: CategoryRendering Server OS: RH 7.2 Last update: 16 years ago

Hi,

The INCLUDE variable has a very useful feature of being able to pass a variable into the included page, e.g.

%INCLUDE{"MyTopic" MYVAR="hello"}%

Will evaluate the string %MYVAR% when MyTopic is rendered. I would like to be able to get the same behaviour when linking to a topic, .e.g.

[[MyTopic MYVAR="hello"][My topic link]] 

Such that when I click on the link to visit MyTopic, the string %MYVAR% is evaluated to the word hello inside the rendered topic.

Can you let me know if this is possible?

Cheers,

Steve.

-- SteveJonesST - 12 Feb 2009

Discussion and Answer

May be I miss something, why not simply write [[%MYVAR%][My topic link]] and define a MYVAR setting as preferences setting or by passing into the INCLUDE?

-- PeterThoeny - 12 Feb 2009

Do you mean:

<a href='%SCRIPTURL{view}%/%WEB%/MyTopic?MYVAR=%URLPARAM{"MYVAR" default="hello"}%'>My topic link</a>

or something?

-- TWikiGuest - 12 Feb 2009

Thanks for the answers so far:

Peter:

I have a small script which is generating some content inside a TWiki topic, which is dependent on MYVAR. This script makes a TWiki table, and inside each cell is a link, gernerated by the script, which points to a generic TWiki topic which should act on the value of a variable passed in by the script.

If I can't pass a variable in to the topic like this, I have to generate a separate TWiki page for each table cell, with a different variable setting on each topic page, but identical content in all other respects, which is slow, and hard to maintain.

TWikiGuest:

Thanks for the suggestion, but for some reason this doesn't expand the variable in the topic. The URL ends up as:

http://cadweb.bri.st.com/twiki/bin/view/Sandbox/TestTopic53?MYVAR=hello

But topic at the end of this link doesn't know that MYVAR = hello. You have pointed me at URLPARAM, which I don't understand, so I will read the docs carefully in case there is a solution there.

All nudges gratefully received.

Steve.

-- SteveJonesST - 13 Feb 2009

For inspiration look into VarINCLUDE, ControlOverVariableExpansion and TWikiTemplates (on variable expansion), VarURLPARAM, TopicCreatePlugin.

-- PeterThoeny - 13 Feb 2009

Closing this question after more than 30 days of inactivity. Feel free to reopen if needed. Consider engaging one of the TWiki consultants if you need timely help. We invite you to get involved with the community, it is more likely you get community support if you support the open source project!

-- PeterThoeny - 2009-04-17

      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 How to pass a TWiki variable into a link
SupportCategory CategoryRendering
TWiki version 4.0.5
Server OS RH 7.2
Web server apache 1.3
Perl version 5.6.0
Edit | Attach | Watch | Print version | History: r7 < r6 < r5 < r4 < r3 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r7 - 2009-04-17 - 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.