Question
Question I am a beginner with TWiki and I very interested in one question.
I create user variable like in example, but I can't get it's value.
%VARIABLE{parameter="value" id="1"}%
When I try to use VARIABLE, I am only see plain text, instead a value:
%VARIABLE{ "parameter" }% %VARIABLE%
I wonder how can I create complicated user variables with many parameters?
Environment
--
SvetlanaGurskaya - 03 Oct 2007
Answer
If you answer a question - or have a question you asked answered by someone - please remember to edit the page and set the status to answered. The status is in a drop-down list below the edit box.
With TWiki's
Set VARNAME = value and
%VARNAME% syntax you can only define variables without parameters. The closest thing you can get is to use parametrized
%INCLUDE%. See
TWiki.VarINCLUDE and
TWiki.IncludeTopicsAndWebPages for complete documentation and examples, here's just a quickstart:
- You define your variables by creating named sections in a topic of your choice, for example VariablesTopic:
%STARTSECTION{"ComplicatedVar"}%
A complex "variable" containing %SOME% %CHANGEABLE% %CONTENT%
%ENDSECTION{"ComplicatedVar"}%
- You use your variable by including that section:
%INCLUDE{"VariablesTopic" section="ComplicatedVar" SOME="very" CHANGEABLE="nice" CONTENT="tricks"}%
- This will result in the following expansion:
A complex "variable" containing very nice tricks
You can have as many such "variables" with differnt section names as you like, all in one topic or distributed. Be careful not to use names of predefined
TWikiVariables for your parameters.
--
HaraldJoerg - 03 Oct 2007
If you know Perl, you can also create a plugin that resolves variables with parameters. See
TWikiPlugins.
--
PeterThoeny - 04 Oct 2007
Thank you for you answer!
--
SvetlanaGurskaya - 04 Oct 2007