Help:Magic Words

Revision as of 23:11, 16 May 2008 by Gboyers (talk | contribs) (New page: {{help}} '''Magic Words''' are phrases recognised by MediaWiki which perform special functions, such as showing a Table of Contents, or the name of the current page. ==Forces== These Mag...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)


Magic Words are phrases recognised by MediaWiki which perform special functions, such as showing a Table of Contents, or the name of the current page.

Forces

These Magic Words force something to show, or be hidden

Magic Word Description
__TOC__ Shows the Table of Contents here, if its required
__NOTOC__ Stops the Table of Contents from showing
__TOC__ Forces the Table of Contents to show here, even if not required
{{toc}} Floats the Table of Contents to the right
{{tocleft}} Floats the Table of Contents to the left
__NOEDITSECTION__ Stops the [edit] links from showing on this page
__NEWSECTIONLINK__ Makes a + button appear next to the edit tab, eg for adding a new section to a talk page
__NOGALLERY__ In a category page, make images show up in a list rather than in a thumbnail gallery
__HIDDENCAT__ In a category page, stops that category from showing up in the horizontal box on the bottom of pages within that category


Variables

These Magic Words echo out the contents of a variable, such as the date, or article name.


Date/Time

Magic Word Example Description
{{CURRENTDAY}} 23 The day of the month (eg 1)
{{CURRENTDAY2}} 23 The day of the month, with a leading zero (eg 01)
{{CURRENTDAYNAME}} Tuesday The full name of the current day
{{CURRENTDOW}} 2 The numeric representation of the day of the week
{{CURRENTMONTH}} 04 The number of the current month, with a leading zero (eg 01)
{{CURRENTMONTHNAME}} April The full name of the current month
{{CURRENTMONTHABBREV}} Apr The abbreviated name of the current month
{{CURRENTTIME}} 23:19 The current time in 24h format
{{CURRENTHOUR}} 23 The current hour in 24h format, with a leading zero
{{CURRENTWEEK}} 17 The current week of the year, with no leading zero
{{CURRENTYEAR}} 2024 The current year
{{CURRENTTIMESTAMP}} 20240423231925 The current ISO 8601 time stamp.
{{LOCALTIME}} 23:19 For most of the above date/time varibles, replacing CURRENT with LOCAL will show the current date/time of the Wiki's default settings, rather than that in the User's preferences.


Wiki Statistics

These variables echo out statistics from this wiki. Numeric values are shown with thousand separators (eg 1,000,000). Adding :R onto the end of some of these (eg {{NUMBEROFEDITS:R}}) will show the number in its raw format, without thousand separators (eg 1000000) which can be used in calculations.

Magic Word Example Description
{{CURRENTVERSION}} 1.40.0 Current version of MediaWiki used on this wiki
{{NUMBEROFEDITS}} 390,491 The total number of edits on this wiki
{{NUMBEROFPAGES}} 56,419 The total number of pages on this wiki, including everything
{{NUMBEROFARTICLES}} 10,039 The total number of articles on this wiki, including only legitimate articles
{{NUMBEROFFILES}} 14,841 The total number of files (images) uploaded to this wiki
{{NUMBEROFUSERS}} 41,892 The total number of Users in the entireity of Wikia
{{NUMBEROFADMINS}} 12 The total number of users on this wiki in the Administrator group
{{PAGESINNS:1}} Template:PAGESINNS:4 Shows the number of pages in a given namespace. The alternative format {{PAGESINNAMESPACE:ns}} may also work.

For the number of pages within a category, see other information (below)


Page Names

Adding an E onto the end of most of these page names will show the same function, but using underscores instead of spaces so it can be used in a web link (URL).

Magic Word Example Description
{{FULLPAGENAME}} Help:Magic Words The full name of the current page. AKA combines {{NAMESPACE}} and {{PAGENAME}}
{{PAGENAME}} Magic Words The name of the page, not including the namespace
{{PAGENAMEE}} Magic_Words The above, but using underscores to be URL-friendly
{{BASEPAGENAME}} Magic Words For subpages, shows the page above it. AKA removes everything after the last slash (/).
{{NAMESPACE}} Help The name of the current namespace
{{TALKSPACE}} Help talk The name of the next odd-numbered namespace. Usually the appropriate talk namespace.
{{SUBJECTSPACE}}
{{ARTICLESPACE}}
Help The name of the previous even-numbered namespace. For talk pages, this will show the namespace of the main article.
{{TALKPAGENAME}} Help talk:Magic Words The full link to the relevant talk page. AKA combines {{TALKSPACE}} and {{PAGENAME}}
{{SUBJECTPAGENAME}}
{{ARTICLEPAGENAME}}
Help:Magic Words The full link to the relevant main article. AKA combines {{SUBJECTSPACE}} and {{PAGENAME}}


Other Page Information

Magic Word Example Description
{{REVISIONID}} 106381 The Unique ID of the current page
{{REVISIONDAY}} 16 The day on which the page was last modified. {{REVISIONDAY2}} shows a leading zero.
{{REVISIONMONTH}} 05 The month on which the page was last modified
{{REVISIONYEAR}} 2008 The year on which the page was last modified
{{REVISIONTIMESTAMP}} 20080516231143 The timestamp of when the page was last modified
{{PAGESINCATEGORY:Cleanup}} 152 The number of pages within a given category. {{PAGESINCAT:category}} also works
{{PAGESIZE:page}} 1,950 The byte size of a given page


Namespaces and URLs

Magic Word Example Description
{{SITENAME}} Grand Theft Wiki The full site name
{{SERVER}} //www.grandtheftwiki.com The URL of the wiki
{{SERVERNAME}} www.grandtheftwiki.com The domain name of the wiki
{{SCRIPTPATH}} The path (after the server name) to the wiki pages
{{ns:1}} Talk The name of a namespace number
{{#special:}} Special:Badtitle Links to a special page
{{localurl:Main Page}} /Main_Page The local URL of a page name
{{localurl:Main Page|action=purge}} /index.php?title=Main_Page&action=purge The local URL of a page name, with parameters
{{localurl:Wikipedia:Category}} http://en.wikipedia.org/wiki/Category The local URL to an external page will show up as a full URL
{{SERVER}}{{localurl:Main Page}} //www.grandtheftwiki.com/Main_Page The full URL to a page is created by using the server URL then adding the full page name in localurl, which turns spaces to underscores
{{SERVER}}{{localurl:{{TALKPAGENAME}}}} //www.grandtheftwiki.com/Help_talk:Magic_Words The full URL to a talk page can be ouput in the same way as a page name
{{SERVER}}{{localurl:{{TALKPAGENAME}}|action=edit}} //www.grandtheftwiki.com/index.php?title=Help_talk:Magic_Words&action=edit The full URL to Edit a talk page can be given using localurl and the edit parameter


Formatting

Magic Word Example Description
{{lc:AbC dEf}} abc def Turns a string to lower case
{{uc:AbC dEf}} ABC DEF Turns a string to upper case
{{lcfirst:TESTing}} testing Makes the first character of a string into lower case
{{ucfirst:testing}} Testing Makes the first character of a string into upper case
{{formatnum:-218744561.35123}} −218,744,561.35123 Formats a number string, adds thousand separator as appropriate. Recognises positive/negative.
{{padleft:7|3}} 007 Pads a number/string (first variable) to the specified length of digits (second variable) to the left using a zero
{{padleft:7|3|X}} XX7 Pads a number/string to the specified length of digits to the left using a specified character (third variable)
{{padright:C|3|S}} CSS Pads a number/string (as above) to the right
{{#language:de}} Deutsch Shows the native name of a language ID code


Image Modifiers

Magic Word Usage Example Description
framed
frame
enframed
[[Image:Blank.jpg|framed|Caption]]
File:Blank.jpg
Caption
Places an image in a frame with a description. Uses original size and stubbornly ignores width parameter if given.

In general, far better to use thumb, as is only suitable for small images.

thumb
thumbnail
[[Image:Blank.jpg|thumb|Caption]]
File:Blank.jpg
Caption
Modifies image size, sets it dependent on user's favorite thumbnail size in one's preferences, or on the given width parameter (see below).
thumb=image.jpg [[Image:Blank.jpg|thumb=clock.svg|Caption]]
File:Blank.jpg
Caption
Shows a thumbnail image of choice
border [[Image:Clock.svg|border]]   Shows a 1px border around the image
40px [[Image:Blank.jpg|40px]] File:Blank.jpg Resizes an image to specified dimensions. If one dimension is specified, it sets the width and maintains the aspect ratio.
50x100px [[Image:Blank.jpg|50x100px]] File:Blank.jpg If two dimensions are specified (width x height), it uses them as maximums . EG it scales image to no more than 50 pixels wide and no more than 100 high, but image scaled to retain its true aspect ratio within the boundary specified.
40px|Caption [[Image:Blank.jpg|thumb|80px|Caption]]
File:Blank.jpg
Caption
Shows a thumbnail of the image, resizes the thumbnail, adds a caption


Image Position

Magic Word Usage Example Description
right Text1 Text1 Text1

[[Image:Blank.jpg|right]] Text2 Text2 Text2
Text3 Text3 Text3

Text1 Text1 Text1
File:Blank.jpg

Text2 Text2 Text2
Text3 Text3 Text3

Floats an image (or thumbnail) right. Text will wrap to the left of it.
left Text1 Text1 Text1

[[Image:Blank.jpg|left]] Text2 Text2 Text2
Text3 Text3 Text3

Text1 Text1 Text1
File:Blank.jpg

Text2 Text2 Text2
Text3 Text3 Text3

Floats an image (or thumbnail) left. Text will wrap to the right of it.
none Text1 Text1 Text1

[[Image:Blank.jpg|none]] Text2 Text2 Text2
Text3 Text3 Text3

Text1 Text1 Text1
File:Blank.jpg

Text2 Text2 Text2
Text3 Text3 Text3

Explicitly states that the image will not float
center
centre
Text1 Text1 Text1

[[Image:Blank.jpg|center]] Text2 Text2 Text2
Text3 Text3 Text3

Text1 Text1 Text1
File:Blank.jpg

Text2 Text2 Text2
Text3 Text3 Text3

Centers an image, still acts like none. Works with either British or American spelling.


Template Modifiers

Magic Word Example Description
{{:xyz}} Xyz A leading colon is the prefix for the name namespace (IE an empty namespace). This will transclude the specified page, not the page within the template: namespace. This example will include Xyz not Template:Xyz.
{{int:xyz}}
{{int:currentevents}}
⧼xyz⧽
Latest News
Includes a page from the MediaWiki namespace. Same as {{mediaWiki:xyz}}, but also doesn't show up under Templates used on this page. Rendered as <xyz> if MediaWiki:xyz doesn't exist.
{{msg:CURRENTYEAR}} Template:CURRENTYEAR Transcludes the template xyz, even if a Magic Word with the same name exists. Usually Magic Words take priority.
{{msgnw:Col-end}}
{{raw:Col-end}}
<p></p>

|}<noinclude>{{protected template}} {{Col-begin/doc}}</noinclude>

Includes the wikitext (markup, raw code) of a page. Does not render the page.
{{subst:xyz}} -- The content of the mentioned page is copied into this page. The include tag is replaced by the markup of the target page. The template will appear to show as normal, but changes to the template will not affect this page.


Other

Magic Word Example Description
{{DISPLAYTITLE:xyz}} -- Changes a page's title, as displayed at in the header at the top of the page
{{CONTENTLANGUAGE}} en-gb The ID Code of the site's default interface language
#REDIRECT [[Page]] -- Automatically redirects this page to another. Cannot be used to redirect across wikis. Cannot redirect more than once at a time. Redirects can be ignored with &redirect=no on the URL.
[[Category:category_name|sort_key]] [[Category:Characters|Johnson, Carl]]

[[Category:Grand Theft Auto IV|Missions]]
When a page is listed on a category page, it will be sorted and listed in alphabetical order. That can be overridden by adding a sort key, which sorts this example for Carl Johnson under J rather than under C, which is useful for Surnames.
This can also be used to eliminate repetition in titles, such as changing Missions in GTA IV to be listed as "Missions".