Help:Variable: Difference between revisions

14 bytes added ,  2 November 2024
Cleanup
m (Muskit Gergous moved page Help:Magic words to Bharatpedia:Magic words)
(Cleanup)
Line 6: Line 6:
{{Bharatpedia how-to|H:MW|BP:MAGIC|BP:MAGICWORD|BP:MAGICWORDS}}
{{Bharatpedia how-to|H:MW|BP:MAGIC|BP:MAGICWORD|BP:MAGICWORDS}}


'''Magic words''' (including '''parser functions''', '''variables''' and '''behavior switches''') are features of [[Help:Wiki markup|wiki markup]] that give instructions to Wikipedia's underlying [[MediaWiki]] software. For example, magic words can suppress or position the table of contents, disable indexing by external search engines, and produce output dynamically based on the current page or on user-defined conditional logic. Some of these features are especially useful for [[BP:Templates|templates]].
'''Magic words''' (including '''parser functions''', '''variables''' and '''behavior switches''') are features of [[Help:Wiki markup|wiki markup]] that give instructions to Bharatpedia's underlying [[MediaWiki]] software. For example, magic words can suppress or position the table of contents, disable indexing by external search engines, and produce output dynamically based on the current page or on user-defined conditional logic. Some of these features are especially useful for [[BP:Templates|templates]].


This page is a quick reference for magic words. For more information, refer to the main MediaWiki documentation:
This page is a quick reference for magic words. For more information, refer to the main MediaWiki documentation:
Line 68: Line 68:
|-
|-
! scope="row" id="NOINDEX" | <kbd><nowiki>__NOINDEX__</nowiki></kbd>
! scope="row" id="NOINDEX" | <kbd><nowiki>__NOINDEX__</nowiki></kbd>
| Instructs search engines not to index the page. See [[Wikipedia:Controlling search engine indexing]].
| Instructs search engines not to index the page. See [[Bharatpedia:Controlling search engine indexing]].
|-
|-
! scope="row" id="STATICREDIRECT" | <kbd><nowiki>__STATICREDIRECT__</nowiki></kbd>
! scope="row" id="STATICREDIRECT" | <kbd><nowiki>__STATICREDIRECT__</nowiki></kbd>
Line 88: Line 88:
== Variables ==
== Variables ==
{{Shortcut|BP:VAR}}
{{Shortcut|BP:VAR}}
{{Further|mw:Help:Magic words#Variables|Wikipedia:Page name#sub}}
{{Further|mw:Help:Magic words#Variables|Bharatpedia:Page name#sub}}
{{Redirect|BP:VAR|policies and guidelines with BP:*VAR shortcuts, mostly about style matters|BP:VARS}}
{{Redirect|BP:VAR|policies and guidelines with BP:*VAR shortcuts, mostly about style matters|BP:VARS}}
{{Redirect|BP:PAGENAME|the article naming policy|Wikipedia:Article titles}}
{{Redirect|BP:PAGENAME|the article naming policy|Bharatpedia:Article titles}}


{| class="wikitable plainrowheaders"
{| class="wikitable plainrowheaders"
Line 103: Line 103:
! scope="row" id="PAGENAME" | <kbd>{<nowiki/>{PAGENAME}}</kbd>
! scope="row" id="PAGENAME" | <kbd>{<nowiki/>{PAGENAME}}</kbd>
| {{PAGENAME}}
| {{PAGENAME}}
| Title line excluding [[Wikipedia:Namespace|namespace]].
| Title line excluding [[Bharatpedia:Namespace|namespace]].
|-
|-
! scope="row" id="BASEPAGENAME" | <kbd>{<nowiki/>{BASEPAGENAME}}</kbd>
! scope="row" id="BASEPAGENAME" | <kbd>{<nowiki/>{BASEPAGENAME}}</kbd>
Line 113: Line 113:
| Title of topmost parent (before all subpages), excluding namespace.
| Title of topmost parent (before all subpages), excluding namespace.
|-
|-
! scope="row" | <kbd>[[wp:pagename#sub|{<nowiki/>{SUBPAGENAME}}]]</kbd>
! scope="row" | <kbd>[[BP:pagename#sub|{<nowiki/>{SUBPAGENAME}}]]</kbd>
| {{SUBPAGENAME}}
| {{SUBPAGENAME}}
| On a subpage, rightmost portion of ''current'' title; higher subpagenames show as [[Breadcrumb navigation|backlinks]].
| On a subpage, rightmost portion of ''current'' title; higher subpagenames show as [[Breadcrumb navigation|backlinks]].
Line 156: Line 156:
|}
|}


''Note:'' The magic words above can also take a parameter, in order to parse values on a page other than the current page. A colon (<kbd>:</kbd>) is used to pass the parameter, rather than a pipe (<kbd>{{!}}</kbd>) that is used in templates, like <kbd><nowiki>{{MAGICWORD:value}}</nowiki></kbd>. For example, <kbd><nowiki>{{TALKPAGENAME:Wikipedia:MOS}}</nowiki></kbd> returns <samp><nowiki>Wikipedia talk:MOS</nowiki></samp> on any page.
''Note:'' The magic words above can also take a parameter, in order to parse values on a page other than the current page. A colon (<kbd>:</kbd>) is used to pass the parameter, rather than a pipe (<kbd>{{!}}</kbd>) that is used in templates, like <kbd><nowiki>{{MAGICWORD:value}}</nowiki></kbd>. For example, <kbd><nowiki>{{TALKPAGENAME:Bharatpedia:MOS}}</nowiki></kbd> returns <samp><nowiki>Bharatpedia talk:MOS</nowiki></samp> on any page.


''Note:'' In the "Category" and "Category talk" namespaces, to wikilink (some) page name variables may require [[help:link|prefixing a colon]] to avoid unwanted categorization.
''Note:'' In the "Category" and "Category talk" namespaces, to wikilink (some) page name variables may require [[help:link|prefixing a colon]] to avoid unwanted categorization.
Line 449: Line 449:
| Outputs ''result1'' if ''expression''{{thinsp}} is true, otherwise outputs ''result2''.
| Outputs ''result1'' if ''expression''{{thinsp}} is true, otherwise outputs ''result2''.
|-
|-
! scope="row" id="ifexist" | <kbd>[[mw:Help:Extension:Parser functions##ifexist|{<nowiki/>{#ifexist:''pagetitle'' {{pipe}}''result1'' {{pipe}}''result2''}}]]{{efn|name=expensive|This function is an [[WP:EXPENSIVE|expensive]] parser function.}}</kbd>
! scope="row" id="ifexist" | <kbd>[[mw:Help:Extension:Parser functions##ifexist|{<nowiki/>{#ifexist:''pagetitle'' {{pipe}}''result1'' {{pipe}}''result2''}}]]{{efn|name=expensive|This function is an [[BP:EXPENSIVE|expensive]] parser function.}}</kbd>
| Outputs ''result1'' if the page [<nowiki/>[''pagetitle'']] exists, otherwise outputs ''result2''. Note that underscores are needed for spaces in namespaces.
| Outputs ''result1'' if the page [<nowiki/>[''pagetitle'']] exists, otherwise outputs ''result2''. Note that underscores are needed for spaces in namespaces.
|-
|-