[Mediawiki-l] Store data in an template
Michael Daly
michael.daly at kayakwiki.org
Sun Apr 20 21:04:24 UTC 2008
Mediawiki wrote:
> is there a way to store general information in a template and access parts
> of that information by a conditional call of the template?
You can do this if you put a long list of #if statements in another
template and nest them accordingly.
For example if you have template DepartmentHeads, you could have
{{ #ifeq: {{{1}}} | Dept X | Smith }}
{{ #ifeq: {{{1}}} | Dept Y | Jones }}
{{ #ifeq: {{{1}}} | Dept Z | Davis }}
etc.
Template PhoneNumbers could have
{{ #ifeq: {{{1}}} | Smith | (888) 555-1234 }}
{{ #ifeq: {{{1}}} | Jones | (888) 555-4321 }}
{{ #ifeq: {{{1}}} | Davis | (888) 555-1221 }}
etc.
Then just include that in the outer template:
The head of {{{dept}}} is {{ DepartmentHeads|{{{dept}}} }}
They can be contacted at {{ PhoneNumbers|{{ DepartmentHeads|{{{dept}}} }} }}
This is a tedious way to create templates as a quasi-database, but if
the data is small in quantity and fairly static over time, it works and
avoids building an extension.
Mike
More information about the MediaWiki-l
mailing list