Wiki Tut Include Variables

Q: How can I set a variable in a Wiki page and INCLUDE that page in another page, maintaining the variable?

Preference variables (using * Set...) do not follow INCLUDEs. This is a known issue/feature. The workaround is to use a SpreadSheetPlugin formula in the INCLUDEd file that sets the variable, e.g. %CALC{$SET(VAR, value)}%, then use %CALC{$GET(VAR)}% in your topic.

See TWiki:Support/FileOfWebVariables for additional information and links.

Example 1

First, view the page we're including from: WikiTutIncludedVar (raw mode). Then come back and see the results (below)

%INCLUDE{"WikiTutIncludedVar"}%

Test:
We did that on %FOODATE%
We did that on %FOODATE%

Result: Failed

Test:
We did that on  %CALC{$GET(FOODATE)}%
We did that on 25Jul08

Result: Succeeded

Example 2

First, view the page we're including from: WikiTutIncludedVar2 (raw mode). Then come back and see the results (below)

%INCLUDE{"WikiTutIncludedVar2" section="Set Variables"}%

Test
%INCLUDE{"WikiTutIncludedVar2" section="test1"}% 

"Rails Plugins: Extending Rails Beyond the Core", James Adam, http://www.mypearsonstore.com/bookstore/product.asp?isbn=0132417995

Result: Succeeded

Test:
%INCLUDE{"WikiTutIncludedVar2" section="test2"}% 

"Rails Plugins: Extending Rails Beyond the Core", James Adam, http://%mps%=0132417995

Result: Failed

Test:
%INCLUDE{"WikiTutIncludedVar2" section="test3"}% 

"Rails Plugins: Extending Rails Beyond the Core", James Adam, http://www.mypearsonstore.com/bookstore/product.asp?isbn=0132417995

Result: Succeeded

-- VickiBrown -- 04 Apr 2011
Topic revision: r2 - 02 Dec 2014, VickiBrown
This site is powered by Foswiki Copyright © by the contributing authors. All material on this wiki is the property of the contributing authors.
Foswiki version v2.1.6, Release Foswiki-2.1.6, Plugin API version 2.4
Ideas, requests, problems regarding CFCL Wiki? Send us email