4 Appendix: Magic words

No edit summary
No edit summary
Line 31: Line 31:


===Variable===
===Variable===
You can use variables to display information about the current page, the wiki or the date.
Variables contain (simple) dynamic data. If a template name conflicts with a variable, the variable is used. For example, you have the variable <code><nowiki>{{PAGENAME}}</nowiki></code>. In that case, you have to transclude the template with the same name as <code><nowiki>{{Template:PAGENAME}}</nowiki></code>.
 
The syntax is the same as that of the templates, so there may be conflicts if the names are the same. If there is a naming conflict between the template and the variable, the variable will be used. If you still want to use the template, you should precede it with ‘Template:’ <code><nowiki>{{Template:Templatename}}</nowiki></code>
{| class="wikitable" style="width:950px;"
{| class="wikitable" style="width:950px;"
! style="background-color:rgb(234, 236, 240);text-align:center;box-sizing:inherit;padding:0.2em 0.4em;border:1px solid rgb(162, 169, 177);" class="" |Variable
! style="background-color:rgb(234, 236, 240);text-align:center;box-sizing:inherit;padding:0.2em 0.4em;border:1px solid rgb(162, 169, 177);" class="" |Variable
Line 67: Line 65:
| style="box-sizing:inherit;padding:0.2em 0.4em;border:1px solid rgb(162, 169, 177);" |Shows the page name as it was created (cf. [[Reference:BlueSpiceHideTitle|changing article titles]])
| style="box-sizing:inherit;padding:0.2em 0.4em;border:1px solid rgb(162, 169, 177);" |Shows the page name as it was created (cf. [[Reference:BlueSpiceHideTitle|changing article titles]])
|}
|}
====Characteristics of a variable====
*'''Purpose:''' returns information about the page, wiki, or date
*'''Syntax:''' <code><nowiki>{{PAGENAME}}</nowiki></code>
====Description====
Variables contain (simple) dynamic data. If a template name conflicts with a variable, the variable is used. For example, you have the variable <code><nowiki>{{PAGENAME}}</nowiki></code>. In that case, you have to transclude the template with the same name as <code><nowiki>{{Template:PAGENAME}}</nowiki></code>.


===Parser Function===
===Parser Function===

Revision as of 11:23, 21 May 2025


A "Magic word" is a string of text that is recognized by the MediaWiki software. It triggers the software to return the value of a function, such as dates, website statistics or page names.

Magic words are inserted directly in the source code.

Types of Magic words

There are basically four different types of Magic words:

Behavior switch

Characteristics of a behavior switch

  • Purpose: controls the layout or behavior of the page
  • Syntax: __NOTOC__

Description

A behavior switch includes or omits certain elements of the page. It is also known as "double underscore". Behavior switches can be put anywhere in the source code of the designated page (usually at the end of the page). The behavior switch __TOC__ produces as output the table of contents exactly where it was inserted on the page.====

Variable

Variables contain (simple) dynamic data. If a template name conflicts with a variable, the variable is used. For example, you have the variable {{PAGENAME}}. In that case, you have to transclude the template with the same name as {{Template:PAGENAME}}.

Variable Output Description
{{SITENAME}} BlueSpice Helpdesk Name of the wiki
{{CURRENTTIME}} 19:13 Time (24-hour HH:mm format)
{{CURRENTDAY}} 23 Current day (no preceding zero)
{{CURRENTMONTH}} 05 Month (with preceding zero)
{{NUMBEROFARTICLES}} 595 Shows the number of all existing articles in the wiki (in the main namespace)
{{NAMESPACE}} Manual Shows the namespace of the article
{{PAGENAME}} MagicWords Shows the page name as it was created (cf. changing article titles)

Parser Function

Characteristics of a parser function
  • Purpose: simple "programming language" for page content (mainly in templates)
  • Syntax: {{#if:{{{field|}}} | {{{field|}}} | N/A }}
Description

Parser functions are similar to variables, but take one or more parameters.Example:

{{#ifeq:{{{type}}}|warning
|This is a warning!
|
}}

They are used for simple logic only, since they are hard to read and to maintain on a larger scale. If complex logic is required, consider Lua scripts in the "Module" namespace (mediawiki.org/wiki/Extension:Scribunto) and invoke using {{#invoke:...}}

Parser functions can also be "tag-like", e.g. {{#ask:...}} from SemanticMediaWiki. For more information, refer to the MediaWiki help pages mediawiki.org/wiki/Help:Extension:ParserFunctions and mediawiki.org/wiki/Help:Magic_words#Parser_functions.

Tag

Characteristics of a tag

  • Purpose: often used for custom development to process dynamic content
  • Syntax: <smartlist />

Description

Tags are implemented in PHP as part of a MediaWiki extension. Tags with "bs:" prefix come from BlueSpice. All others come from MediaWiki or from third-party extensions, e.g. the extension SyntaxHighlight.

Related info



PDF exclude - start

To submit feedback about this documentation, visit our community forum.

PDF exclude - end