Tags:
create new tag
view all tags

SID-00188: How to set variables for a topic hierarchy?

Status: Answered Answered TWiki version: 4.0.4 Perl version:
Category: CategoryRendering Server OS: Last update: 16 years ago

I'd like to set variables in a topic whose values were propagate to all sub-topics in topic hierarchy. I tried %INCLUDE% including a page with the settings with no success... Is there any way to do that?

-- WeberSotomba - 13 Mar 2009

Discussion and Answer

An INCLUDEd page does not inherit variables.

As a workaround you can use a SpreadSheetPlugin VarCALC: $SET() a variable in the INCLUDEd page, and $GET() the variable in the including page. See working example at Sandbox.SpreadSheetRollupTest.

-- PeterThoeny - 13 Mar 2009

It worked indeed. I tried another approach using a more regular var setting, like this:

<!--
VAR=0304
-->

It worked but the var "importing" is quite clumsy:

   * Set VAR = %<nop>INCLUDE{"SetIncludedVarsSet" pattern=".*?VAR=(\S+).*"}%

There is a more complete example on SetIncludedVars .

It seems to me that a good solution would be some way to evaluate Set VAR = <value> statements that would be dynamically created by an %EXTRACT{"SetIncludedVarsSet"}% command.

Obviously I have no clue if it is feasible wink

-- WeberSotomba - 14 Mar 2009

See also proposed feature to MakingVarVARTopicCapable.

-- PeterThoeny - 16 Mar 2009

Right, that is a better way of importing a single variable. But to import a bunch of vars, it seems that a good way (if system architecture allows that) would be some kind of routine to evaluate a string in the current topic, alike the Perl eval() routine. For instance:

   %STR_EVAL("   * Set VAR = 0304$n   * Set VAR2 = \"This string\"")%

The string could be generated by a %EXTRACT{}% processing the topic with the var settings.

Is this feasible? This routine would have a number of other uses, I guess.

Tks for your assistance.

-- WeberSotomba - 16 Mar 2009

      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 set variables for a topic hierarchy?
SupportCategory CategoryRendering
TWiki version 4.0.4
Server OS

Web server

Perl version

Edit | Attach | Watch | Print version | History: r6 < r5 < r4 < r3 < r2 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r6 - 2009-03-16 - WeberSotomba
 
  • 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.