Tags:
create new tag
, view all tags
ALERT!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}% =>

Key Value
var1 val2
var2 val2
...
varN valN

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)
    • Set DEBUG = 0

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

Plugin Author: TWiki:Main.MikeEggleston
Copyright: © 2006, TWiki:Main.MikeEggleston
License: GPL (GNU General Public License)
Plugin Version: 20 Nov 2006 (V1.000)
Change History:  
20 Nov 2006: Initial version
TWiki Dependency: $TWiki::Plugins::VERSION 1.1
CPAN Dependencies: none
Other Dependencies: none
Perl Version: 5.005
Benchmarks: GoodStyle nn%, FormattedSearch nn%, VariablesPlugin nn%
Plugin Home: http://TWiki.org/cgi-bin/view/Plugins/VariablesPlugin
Feedback: http://TWiki.org/cgi-bin/view/Plugins/VariablesPluginDev
Appraisal: http://TWiki.org/cgi-bin/view/Plugins/VariablesPluginAppraisal

Related Topics: TWikiPlugins, DeveloperDocumentationCategory, AdminDocumentationCategory, TWikiPreferences

-- TWiki:Main.MikeEggleston - 20 Nov 2006

Topic attachments
I Attachment History Action Size Date Who Comment
Compressed Zip archivezip VariablesPlugin.zip r1 manage 5.3 K 2006-11-20 - 22:00 MikeEggleston  
Edit | Attach | Watch | Print version | History: r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r3 - 2006-11-21 - 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-2017 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.