phatmanace
phatmanace

Reputation: 5021

site wide (global) variables on mediawiki

Folks,

I'd like to have similar set up to the one discussed in this question

Can I use templates to form a set of variables that I can then later include in various points in my wiki pages.

so for example have varables in my single template called MAIN_WEB_URL and MAIN_TEAM_DISTRIBUTION_LIST that I can store in a single template and reference site-wide where needed.

I'd like to avoid a template per variable if possible, but the other question seems to imply this is the only way to do it...

Upvotes: 1

Views: 312

Answers (1)

svick
svick

Reputation: 244787

One way to do this would be to create a template called something like Template:Variable. In it, you would use one big {{#switch}} that would contain the variables and their values (this requires the ParserFunctions extension):

{{#switch: {{{1}}}
| MAIN_WEB_URL = some value
| MAIN_TEAM_DISTRIBUTION_LIST = another value
}}

You would then call it like this:

{{variable|MAIN_WEB_URL}}

(BTW, I am not a fan of ALL_CAPS names and I think there is no reason to use them here, but that's up to you.)

Upvotes: 1

Related Questions