variableswikipediawiki

How can I set a variable in the MediaWiki


I'm looking for an oppertunity to set a variable in the wikipedia code.

something like this

year1 = "2002"

and then just to write year1 instead of 2002. Because if I want to change 2002 to 2004 I don't have to change twenty times the 2002, just only year1 once.


Solution

  • Mediawiki the software platform for Wikipedia offers a feature called Template, which is equivalent to macro in programming context. As per this you can create a page called Template:year1 with the contents "2002". Then in the article pages whenever you use {{year1}}, it will be replaced with its definition when the article page is presented. If you need to change the value to 2004, you can change in the template page and all the article pages which use the template will be updated, when they are rendered.