મદદ:Magic words

વિકિપીડિયામાંથી

Magic words (including parser functions, variables and behavior switches) are features of 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 templates.

This page is a quick reference for magic words. For more information, refer to the main MediaWiki documentation:

General information[ફેરફાર કરો]

In general, there are three types of magic words

  1. Behavior switches: often appear in double underscores, all uppercase, e.g., __NOTOC__. They will change the behavior of a page, rather than return a value.
  2. Parser functions: all in lowercase. A parser function will be followed by colon and pipe-separated parameters, e.g., {{#ifexpr:Y|Yes|No}}, wrapped in double braces. They will take a value and return a value.
  3. Variables: these are all uppercase, e.g., {{PAGENAME}}. A variable will be wrapped in double braces and will return a value in its place.

The software generally interprets magic words in the following way.

  • Magic words are case sensitive.
  • White space is generously allowed for readability. It will be stripped from the start and end of their keywords and parameters (as is also done inside templates).
  • They can be transcluded, even variables "about the current page". This is ensured by the parsing order.
  • Instead of magically transforming into HTML instructions, <nowiki> tags remove this magic so a magic word can itself be displayed (documented), e.g. <nowiki>{{#magic:}}</nowiki> or {{#magic:<nowiki />}}.

Magic words compared to templates:

  • As with templates, magic words can be transcluded and substituted.
  • The names of magic words are purposely chosen to be unlike the names of templates, and vice versa. Many parser function names will begin with a # (pound or hash), but template names will not start with a #, and probably not end in a : (colon), or be all-uppercase.
  • The first parameter's syntax differs. In {{#magic: p1 | p2 | p3}}, the name is #magic and it is followed by an unspaced : and a required input parameter, p1. With a template, p1 is optional and it is preceded by a | (pipe) instead of a :, e.g. {{template|p1}}.

Behavior switches[ફેરફાર કરો]

Switch Description
__TOC__ Places the page's table of contents (TOC) at the word's position.
__FORCETOC__ Forces the TOC to appear in its default position, even when there are fewer than four headings. Can be used anywhere on a page.
__NOTOC__ Suppresses the appearance of the page's TOC. Can be used anywhere on a page.
__NOEDITSECTION__ Hides the "edit" links normally beside all headings on the page. To hide the edit link beside a particular heading, specify the heading using e.g. an HTML tag such as <h2>heading</h2> rather than with the usual wiki equals-signs syntax (e.g. == heading ==).
__NEWSECTIONLINK__ On non-talk pages, adds a "નવો વિષય" link as a means to add a new section to the page.
__NONEWSECTIONLINK__ Removes the "નવો વિષય" link (the add-new-section link) on talk pages.
__NOGALLERY__ Replaces thumbnails on a category page with normal links.
__HIDDENCAT__ Makes a category hidden when included on that category's page.
__INDEX__ Instructs search engines to index the page.
__NOINDEX__ Instructs search engines not to index the page. See Wikipedia:Controlling search engine indexing.
__STATICREDIRECT__ Prevents the link on a redirection page from being updated automatically when the page to which it redirects is moved (and "Update any redirects that point to the original title" is selected).
__DISAMBIG__ Marks a page as a disambiguation page, adds it to Special:DisambiguationPages and places inward links in Special:DisambiguationPageLinks. (See mw:Extension:Disambiguator.)
{{DISPLAYTITLE:title}} Used to amend the displayed form of the page's title.
{{DEFAULTSORT:sortkey}} Sets the default key (the index) under which the page is categorised.
{{NOEXTERNALLANGLINKS}} (equivalent to {{NOEXTERNALLANGLINKS|*}}) Suppresses the automated inclusion of Wikidata interlanguage links on the lefthand side of the page. Links to particular rather than all languages may be suppressed by using {{NOEXTERNALLANGLINKS|list}}, where list a pipe-delimited list of language codes (e.g. {{NOEXTERNALLANGLINKS|fr|es|ja}} to suppress the French ("fr"), Spanish ("es") and Japanese ("ja") interlanguage links).

Page name variable Output Description
{{FULLPAGENAME}} મદદ:Magic words Canonical page name. Title line. Title unless letter-case is altered with {{DISPLAYTITLE}}.
{{PAGENAME}} Magic words Title line excluding namespace.
{{BASEPAGENAME}} Magic words Title of parent page, excluding namespace.
{{ROOTPAGENAME}} Magic words Title of topmost parent (before all subpages), excluding namespace.
{{SUBPAGENAME}} Magic words On a subpage, rightmost portion of current title; higher subpagenames show as backlinks.
{{ARTICLEPAGENAME}} મદદ:Magic words Title of the subject page associated with the current page. These are useful on talk pages (but see note about Category talk pages).
{{SUBJECTPAGENAME}} મદદ:Magic words
{{TALKPAGENAME}} મદદની ચર્ચા:Magic words Title of the talk page associated with the current page. Useful on subject pages.
{{NAMESPACENUMBER}} 12 Number of the current page's namespace.
{{NAMESPACE}} મદદ Namespace of the title.
{{ARTICLESPACE}} મદદ On a talk page, the namespace part of the title of the associated subject page.
{{SUBJECTSPACE}} મદદ
{{TALKSPACE}} મદદની ચર્ચા Namespace of the talk page associated with the current page.
{{FULLPAGENAMEE}},
{{PAGENAMEE}},
 (etc.)
%E0%AA%AE%E0%AA%A6%E0%AA%A6:Magic_words,
Magic_words,
(etc.)
Adding an E to the end of the above variables, renders the above encoded for use in MediaWiki URLs (i.e. with underscores replacing spaces).
{{SHORTDESC}} Only works on the English Wikipedia, where it displays a short description below the article title on mobile platforms.

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 (:) is used to pass the parameter, rather than a pipe (|) that is used in templates, like {{MAGICWORD:value}}. For example, {{TALKPAGENAME:Wikipedia:MOS}} returns Wikipedia talk:MOS on any page.

Note: In the "Category" and "Category talk" namespaces, to wikilink (some) page name variables may require prefixing a colon to avoid unwanted categorization.