NOTE: |
This plugin is obsoleted; its functionality is covered by TWiki's internal variable setting, such as: * Set MYVAR = anything |
VariablesPlugin
Use variables in your topics.
Introduction
Sometimes you want to have the same word, color, or text in many places.
Instead of manually editing the topic page define a variable at the top that
is used everywhere in the topic. You can change the value of a variable
several times in a single topic. All references to a variable will use the
most recent definition. The empty set ('') may be used to define nothing.
This PlugIn defines four 'functions'. You may either set a variable to a
value, request the value of a variable, delete a variable, or list all
variables. It is valid to request the value for a variable that is not yet
set. The value 'undefined' is returned in this case. The list of defined
variables returned by %VARIABLELIST% uses the
TablePlugin syntax.
Syntax Rules
Use the
{key,value} form to define a variable and use the
{key} form to
get the current value of
key.
-
%VARIABLE{key,value}%
-
%VARIABLE{key}%
-
%VARIABLEDELETE{key}%
-
%VARIABLELIST{key}%
Examples
- %VARIABLEDEFINE{company, 'Widgets, Inc.'}%
- %VARIABLERETURN{company}% => 'Widgets, Inc.'
- %VARIABLERETURN{othercompany}% (not yet defined) => 'undefined'
- %VARIABLEDELETE{company}% => nothing
- %VARIABLELIST{company}% =>
...
Define three values and cause the background of text to be the defined color.
%VARIABLEDEFINE{owned,#BBFFBB}%
%VARIABLEDEFINE{leased,#FFCCFF}%
%VARIABLEDEFINE{retired,#EEEEEE}%
%VARIABLELIST%
<style background-color:%VARIABLERETURN{owned}%>owned=%VARIABLERETURN{owned}%</style>
<font color=%VARIABLERETURN{leased}%>leased=%VARIABLERETURN{leased}%</font>
<font color=%VARIABLERETURN{retired}%>retired=%VARIABLERETURN{retired}%</font>
%VARIABLEDEFINE{owned,#BBFFBB}%
%VARIABLEDEFINE{leased,#FFCCFF}%
%VARIABLEDEFINE{retired,#EEEEEE}%
%VARIABLELIST%
owned=%VARIABLERETURN{owned}%
leased=%VARIABLERETURN{leased}%
retired=%VARIABLERETURN{retired}%
Define a table using a background color that comes from a variable.
,%VARIABLERETURN{leased}%,%VARIABLERETURN{retired}%" }%
| Colors |
| Owned |
| Loaned/Leased |
| Retired |
%TABLE{ tableframe="box" sort="off" tablewidth="100%" columnwidths="20%,80%" databg="%VARIABLERETURN{owned}%" cellpadding="2" tableborder="1" }%
" cellpadding="2" tableborder="1" }%
| hostname |
hank |
| make |
Dell |
VariablesPlugin Settings
- One line description, is shown in the TextFormattingRules topic:
- Set SHORTDESCRIPTION = Set and use variables in TWiki topics
- Debug plugin: (See output in
data/debug.txt)
Plugin Installation Instructions
Note: You do not need to install anything on the browser to use this plugin. The following instructions are for the administrator who installs the plugin on the TWiki server.
Extract VariablesPlugin.zip, edit the VariablesPlugin-topic to
your needs and have fun. There is an install script at the top of
the unpacked director that might help with installing this plugin.
Also, enable the plugin using the configure script in twiki.
Execute this script by:
- # unzip -v VariablesPlugin.zip
- # cd twikiVariables
- # ./install.sh /var/www/html/twiki
- change the above path to where your twiki is installed
Files
-
lib/TWiki/Plugins/VariablesPlugin.pm
-
data/TWiki/VariablesPlugin.txt
Plugin Info
Related Topics: TWikiPlugins,
DeveloperDocumentationCategory,
AdminDocumentationCategory,
TWikiPreferences
--
TWiki:Main.MikeEggleston
- 20 Nov 2006