Skip to topic | Skip to bottom
Home
Web attivi: Reteisi | Pmb
user: TWikiGuest
Mappa | Indice | Cambiamenti | Cerca | Vai a | Calcolatrice

Sei qui: TWiki > TopicVarsPlugin



Start of topic | Skip to actions

TopicVarsPlugin TWiki Plugin

This plugin will allow you to create variables in arbitrary topic pages, and not just WebPreferences. You can then refer to those variables from any topic within the same Web or Wiki, and pass in parameters to those vars to make them appear in URLPARAM. This allows you to build TWiki:Codev.TWikiApplications by bundling sets of directives on a page and then using them from elsewhere.

(Perhaps a future iteration will support Interwiki references, but that's probably not likely, unless we use XML-RPC or something to cut down the overhead of getting those values from afar.)

Syntax Rules

  • Set a variable:
    * Set VARIABLE_NAME = "some value"

  • Use a variable in the same Web:
    %TopicName.VARIABLE_NAME%

  • Use a variable from a different Web:
    %Webname.TopicName.VARIABLE_NAME%

Parameterised:

  • Set a variable:
    * Set VARIABLE_NAME = "some value %URLPARAM{parameter}"

  • Use a variable in the same Web:
    %TopicName.VARIABLE_NAME{parameter="Custard"}%

  • Use a variable from a different Web:
    %Webname.TopicName.VARIABLE_NAME{parameter="Custard"}%

(setting values is done just like in WebPreferences; with six preceding spaces, an asterisk, and so on).

Caveats

  1. The URLPARAM thing will not work unless the plugin is running in a CGI environment. You'll get a note in the warning log otherwise.
  2. You cannot use two queries with the same parameter sets on the same page - the second definition will override the first.
  3. Variables (variable is a silly name - think directive or macro) cannot be parameterised in the %VAR% form, only in the %TOPIC.VAR% form - I did this because I got conflicts with META.

TopicVarsPlugin Settings

  • One line description, is shown in the TextFormattingRules topic
    • Set SHORTDESCRIPTION = Set variables in arbitrary topics and refer to them from other topics within the same web; these can be parameterised thus facilitating the packaging of TWiki:Codev.TWikiApplications

Plugin Installation Instructions

  • Download the ZIP file from the Plugin web (see below)
  • Unzip TopicVarsPlugin.zip in your twiki installation directory. Content:
    File: Description:
    data/TWiki/TopicVarsPlugin.txt Plugin topic
    lib/TWiki/Plugins/TopicVarsPlugin.pm Plugin Perl module
  • Check this topic here if the installation was successful
  • Test if the plugin is correctly installed:
    • Set THE_ANSWER = 42
    • You should see the answer here: [42] (%THE_ANSWER%)
    • and here: [42] (%TopicVarsPlugin.THE_ANSWER%)
    • and here: [42] (%TWiki.TopicVarsPlugin.THE_ANSWER%)
  • And now with parameters
    • Set THE_PARAMETERISED_ANSWER = I like
    • Here: [I like Jelly] (%TopicVarsPlugin.THE_ANSWER{parameter="Jelly"}%)
    • and here: [I like Jelly] (%TWiki.TopicVarsPlugin.THE_ANSWER{parameter="Jelly"}%)

Plugin Info

Plugin Author: TrippLilley?
Plugin Version: 23 Jul 2021
Change History: 15 Nov 2001: Initial version
23 Jul 2003: Update to incorporate debug log undefined variable patch
11 Apr 2004: Update to allow parameters to define URLPARAM space
CPAN Dependencies: none
Other Dependencies: none
Perl Version: 5.0
Plugin Home: http://TWiki.org/cgi-bin/view/Plugins/TopicVarsPlugin
Feedback: http://TWiki.org/cgi-bin/view/Plugins/TopicVarsPluginDev

Related Topics: InterwikiPlugin

-- TrippLilley? - 15 Nov 2021


TWiki.TopicVarsPlugin r1.1 - 09 Aug 2021 - 04:14 - Main.www-data
Copyright © 1999-2006 degli autori degli articoli. Tutto il materiale presente su questa piattaforma collaborativa Ŕ di proprietÓ di chi l'ha prodotto. Idee, richieste, problemi relativi a TWiki? Invia feedback