Author: ReneeMattie
Description:
User-defined variables are useful while an article is being written.
I could write the code, but have nowhere to test my work...
BENEFIT OF EXTENSION:
Example 1: Keep a group of images the same size
Editor has several images on page, needs them all the same size.
Editor decides to change the size of all the images. The ability
to create and use a variable would make this a lot easier
<VarSet>imagesize=250px</VarSet>
[[Image:imageA.jpg|<VarGet>imagesize</VarGet>]]
[[Image:imageB.jpg|<VarGet>imagesize</VarGet>]]
... a lot of text ...
[[Image:imageC.jpg|<VarGet>imagesize</VarGet>]]
Example 2: Print or Supress all footnotes
A set of children's books is being developed at WikiJunior.
During development, we want to display citations so we can see which
facts have been checked and which have not. After development, we
would like to supress display of citations, because they are not
used in children's books. But we would not like to have to delete
all of the citations.
We could create a set of templates that would depend on the value of
a single variable -- showrefs. At the top of the document,
<!-- Today, no refs --><VarSet>showrefs=0</VarSet>
In Template:WJFootnote we have {{WJCite<VarGet>showrefs</VarGet>}}
Which would select template WJCite0 (which does nothing) or WJCite1
(which generates the citation reference) depending on how showrefs
was set at the top of the document
IMPLEMENTATION:
$uservar['myvar']='string'
The variables would only exist during the display of a page.
The variables MUST BE GLOBAL --accessible even within nested
templates
The variables SHOULD BE passable as parameters to templates.
The variables COULD BE made available when an editor was
editing/previewing only one section of the page if, for example,
they were stuffed into a new magic word.
USER INTERFACE:
Variables would be manipulated by a set of wiki extensions:
VarSet
<VarSet>myvar</VarSet> <VarSet>myvar="string"</VarSet> <VarSet>myvar=6.02E23</VarSet> sets the variable, produces no output. if no value is given for myvar, default value is 1
VarIsSet
<VarIsSet>myvar</VarIsSet> returns 1 or 0, which could be incorporated into a templatename
VarGet
<VarGet>myvar</VarGet> returns the value of myvar if the var is not set, produces no output
VarUnSet
<VarUnSet>myvar</VarUnSet> unsets the variable, produces no output.
Version: unspecified
Severity: enhancement