Од Википедија — слободната енциклопедија
Прејди на прегледникот Прејди на пребарувањето

Шаблон:H:h Помош Под променлива се подразбира предефиниран шаблон без параметри. Види исто така Помош:Расчленувачка функција.

Следи листа на променливи кои можат да се користат во виитестот. Начинот на кој тие се рендерираат може да се разликува во зависност од времето (директно зависни од времето или од бројот на статии, зависни од времето на креирање на другите статии и сл.), проектот (тие се менуваат кога викитекстот е копиран), или од станицата во која тие се појавуваатт (се менуваат кога викитекстот се копира или кога страницата е преименувана или кога страницата е вклучена во некоја друга страница).

На левата страна е променливата а на десната страна како таа е рендерирана во дадено време, во даден проект и дадена страница.

Имињата на променливите го формираат делот од таканареченото множество на "магични зборови" кои системот ги користи.

With Special:ExpandTemplates one can view the value of a variable, or more generally, the expanded wikitext a variable or a wikitext with variables and/or template calls produces, as intermediate step toward rendering.

Константи[уреди | уреди извор]

{{SITENAME}} Википедија
{{SERVER}} //mk.wikipedia.org
{{SERVERNAME}} mk.wikipedia.org
{{CONTENTLANGUAGE}} mk code of the site's default interface language ($wgLanguageCode)

Depending on page[уреди | уреди извор]

H:Page name variables

For the rendering on page A, these variables depend on page A, even if page A contains the variable due to inclusion of page B. Variables in the sort key of a category tag refer to the page with the tag, not the category page where it takes effect.

{{NAMESPACE}} and {{NAMESPACEE}} return an empty string in the article namespace {{ns:0}}, see above and NS:0.

PAGENAMEE displays the page title in the form that is used in URLs, i.e. with underscores for spaces, and percent-encoding for special characters, and is therefore used for constructing URLs incl. query strings.

For example, on Template talk:!, SUBJECTPAGENAMEE would produce Template:%21. Don't encode PAGENAMEE etc. again, i.e. don't use it in the first parameter of fullurl: and similar parser functions, {{urlencode:%21}} = %2521 probably won't work as expected. Query strings  in PURL redirections are an exception.

The "EE" encoding examples shown above for this page are not very interesting, only TALKPAGENAMEE and TALKSPACEE differ from TALKPAGENAME and TALKSPACE. See Help:Link and Help:Magic words for other examples.

In a subpage, [[../]] renders as a link to the parent page. For example, on m:Link/a/b it gives an internal link to m:Link/a, see Help:Link#Subpage feature.

"{{REVISIONID}}" gives „3205773“ [1] showing the current unique revision number of a saved page as used for diffs in the page history is in essence useless, it can't be substituted and also doesn't work in preview.

Varying with time[уреди | уреди извор]

Time[уреди | уреди извор]

The time in UTC. Note that if the page was displayed by the same user and has not changed (page has not been edited) since the last time it was displayed, it is possible that the page may be cached (by the user's browser) and the displayed time or date may not change. Also, if a heavily used page, rather than freshly rendered by the software each time it is generated, is instead being retrieved from a caching system (such as the main page on Wikipedia) the date or time may not change from the last time the page was originally retrieved by the caching hardware or software. Шаблон:H:Current time variables

Local time[уреди | уреди извор]

The time depending on the local timezone of the wiki (not depending on the timezone in the user's preference settings). (All words [MW1.8+] ) Шаблон:H:Local time variables

Time variables which change more often than once a day are generally useful only as curiosities. Because of the way article HTML is cached, these variables may be wrong by up to 24 hours, and so are not a reliable way to tell the user the current time.

Please note that a template using more than one CURRENT variable directly or indirectly is suspicious. There can be critical races near hh:mm:59. The following code to determine the minute can produce spurious results if the timestamp changes during the evaluation: {{#expr:(( {{CURRENTTIMESTAMP}}-{{CURRENTTIMESTAMP}} mod 100)/100) mod 100}} = 19
This is actually an intermittent bug with MOD depending on the size (not the value) of CURRENTTIMESTAMP, see Шаблон:Tim.

0=Sunday, 1=Monday, .. 6=Saturday.
is the number of the current week (1-53) according to ISO 8601 with no leading zero.
adds a leading zero to days 1...9, this allows to construct the ISO date formats like 2018-07-20T03:19Z.
is the genitive grammatical form of the month name (used in Finnish Шаблон:Unclear and in Slovenian).
see Help:Article count and Special:Statistics..

Statistics[уреди | уреди извор]

See Statistics.

Substitution[уреди | уреди извор]

Main article: Help:Substitution

When {{<includeonly>subst:</includeonly>CURRENTTIMESTAMP}} is included and thereby substituted, the timestamp of doing that is put in the wikitext, and similarly for other variables. Examples:

20180720031948 - stays a variable on pages including the template
20060526024210 - became a substituted constant in the template
20180720031948 - becomes a constant at the time of its inclusion

Templates with the "includeonly subst magic" must also be subst-ed.

Examples of combinations with parser functions[уреди | уреди извор]

[[{{NAMESPACE}} talk:{{PAGENAME}}]]
Помош talk:Променливи
{{fullurl:{{NAMESPACE}} talk:{{PAGENAME}}}}

The old form {{SERVER}}{{localurl:page }} is in essence the same as {{fullurl:page }} in recent (1.5+) versions of the software.

In a template, for a link to a page which depends on a template parameter, the external link style is used even for internal links, to avoid that the system links to the edit page even if the page exists. To construct the external link, variables can also be useful.

Variable in the form of a template call[уреди | уреди извор]

If the syntax of a template call with parameters is applied with the name of a variable, depending on the variable the parameters are either ignored or cause the variable to be interpreted as a (non-existing) template:

  1. Variables like {{NUMBEROFPAGES:R}} = 434800 with a "raw" format are always handled as variable, {{NUMBEROFPAGES:R|Para|meter}} = 434800.
  2. Other variables like {{CURRENTDAYNAME}} = петок are handled as template for given parameter(s), {{CURRENTDAYNAME|x}} = Шаблон:CURRENTDAYNAME.
  3. Parser functions like {{lc: Lower Case}} = lower case ignore extraneous parameters, {{lc: Lower|Case}} = lower.
  4. Parser function ns (e.g. {{ns: 1}} = Разговор) gives an empty string for a non-applicable numerical parameter value, and evaluates in the case of a non-numerical parameter value as template (the template name being the whole text until "|" or "}}"):
    {{ns: 1234}} =
    {{ns: t|abc}} = Шаблон:Ns: t
  5. Parser functions like fullurl don't support the ../ notation, and in namespaces supporting subpages this has odd effects: like above, they evaluate such an invalid parameter value as template, see Link/a and Link/a/b. Here it just renders the wikitext:
    {{fullurl:../a}} = Шаблон:Fullurl:../a.
    The cases #2, #4, and #5 resulting in template calls are probably related.

Adding new variables[уреди | уреди извор]

A simple means of adding new MediaWiki variables is to add the following code to the LocalSettings.php file. This code also adds two example variables, CURRENTUSER and LOGO. It uses the ParserGetVariableValueSwitch hook which was added into MediaWiki 1.60, so for earlier versions you will have to add the hook manually into the /includes/Parser.php script in the getVariableValue function. See MW:Extension:Variables for the code to add new variables.

Поврзано[уреди | уреди извор]