Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Search
Search
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Help:Transclusion
(section)
Help page
Discussion
English
Read
Edit source
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit source
View history
General
What links here
Related changes
Special pages
Page information
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Transclusion syntax== The general [[Syntax (programming languages)|syntax]] for [[Transclusion|transclusion]] on Wikipedia is <syntaxhighlight lang="wikitext" inline>{{Namespace:Pagename}}</syntaxhighlight>, where <code>[[wikipedia:WP:Namespace|Namespace]]:[[wikipedia:WP:Page name|Pagename]]</code> describes the title of a Wikipedia page. Using transclusion syntax requires some knowledge of page titles. On Wikipedia, non-article pages have titles with a visible namespace and pagename separated by a colon; for example, the page [[Wikipedia:Tips]] has <code>Wikipedia</code> as the namespace, and <code>Tips</code> as the pagename. But encyclopedic articles only have a visible pagename in their titles: for example the article [[Potato]] has <code>Potato</code> as the pagename, and the namespace, called [[Wikipedia:What is an article?#Namespace|main namespace]], is not visible. * The [[Help:Wikitext|wikitext]] <syntaxhighlight lang="wikitext" inline>{{Namespace:Pagename}}</syntaxhighlight> will transclude the page titled <syntaxhighlight lang="wikitext" inline>Namespace:Pagename</syntaxhighlight>. For example, if a page has the wikitext <syntaxhighlight lang="wikitext" inline>{{Wikipedia:Notability}}</syntaxhighlight> in it, it will transclude the page [[Wikipedia:Notability]] into it. Please note that <syntaxhighlight lang="wikitext" inline>{{WP:Notability}}</syntaxhighlight> would do exactly the same thing, as <code>WP:</code> is a [[Wikipedia:Namespace#Aliases|namespace alias]], which is [[Wikipedia:Shortcut#Namespace_aliases|automatically translated]] by the Wikipedia servers to <code>Wikipedia:</code>. *If the namespace is omitted, but the colon is included, like <syntaxhighlight lang="wikitext" inline>{{:Pagename}}</syntaxhighlight>, the encyclopedic article <code>Pagename</code> will be transcluded. For example, <syntaxhighlight lang="wikitext" inline>{{:Notability}}</syntaxhighlight> will transclude the article [[Notability]]. *If both namepace and colon are omitted, like <syntaxhighlight lang="wikitext" inline>{{Pagename}}</syntaxhighlight>, the <code>Template:Pagename</code> will be transcluded. For example <syntaxhighlight lang="wikitext" inline>{{Notability}}</syntaxhighlight>, and also <syntaxhighlight lang="wikitext" inline>{{Template:Notability}}</syntaxhighlight>, will both transclude the [[Template:Notability]]. So, in summary, an example page having the wikitext <syntaxhighlight lang="wikitext" inline>{{Pagename}}</syntaxhighlight> or <syntaxhighlight lang="wikitext" inline>{{Template:Pagename}}</syntaxhighlight> included, will transclude the <code>Template:Pagename</code> into that example page. But <syntaxhighlight lang="wikitext" inline>{{:Pagename}}</syntaxhighlight> will have a different effect: it will transclude the article <code>Pagename</code>. Also, <syntaxhighlight lang="wikitext" inline>{{Namespace:Pagename}}</syntaxhighlight> will transclude the page <syntaxhighlight lang="wikitext" inline>Namespace:Pagename</syntaxhighlight>, for pages with titles of that format. You also have the option of using [[#Template parameters|template parameters]] and [[#Transclusion modifiers|transclusion modifiers]]. ===Subpages=== [[Wikipedia:Subpages|Subpages]] are pages separated with a "/" (a slash) from their 'parent' page. For a parent page with the name format <code>Namespace:Pagename</code>, its subpage name would have the format <code>Namespace:Pagename/Subpagename</code>. This feature is disabled in the main, file, and MediaWiki [[Wikipedia:Namespace|namespaces]], but not on their corresponding talk namespaces. To transclude a subpage: * The general syntax is <syntaxhighlight lang="wikitext" inline>{{Namespace:Pagename/Subpagename}}</syntaxhighlight>. * On the parent page of a subpage, it is either the general syntax or <syntaxhighlight lang="wikitext" inline>{{/Subpagename}}</syntaxhighlight>. * For a template namespace page, it is either the general syntax or <syntaxhighlight lang="wikitext" inline>{{Pagename/Subpagename}}</syntaxhighlight>. * Article subpages are disabled on this wiki, but would otherwise be <syntaxhighlight lang="wikitext" inline>{{:Pagename/Subpagename}}</syntaxhighlight>. * You also have the option of using [[#Template parameters|template parameters]] and [[#Transclusion modifiers|transclusion modifiers]] For example, to transclude [[Template:Like/doc]], it would be either <syntaxhighlight lang="wikitext" inline>{{Template:Like/doc}}</syntaxhighlight> or <syntaxhighlight lang="wikitext" inline>{{Like/doc}}</syntaxhighlight>. Note that subpage names are case sensitive, and <syntaxhighlight lang="wikitext" inline>{{Like/Doc}}</syntaxhighlight> would not work. ===Template parameters=== {{anchor|Template transclusion}} {{further|Help:Template#Parameters}} {{for|a quick guide to templates|Help:A quick guide to templates}} The most common application of transclusion is the transclusion of [[Help:Template|templates]]. Templates are pages that are written with the prime objective of being included in other pages, either through transclusion or [[wikipedia:Help:Substitution|substitution]]. As shown above, the usual syntax for transcluding a template titled Template:Pagename is <syntaxhighlight lang="wikitext" inline>{{Pagename}}</syntaxhighlight>. However, some templates can also use [[parameter]]s. Parameters are [[Variable (computer science)|variables]] that can be given values (also termed [[Parameter_(computer_programming)#Parameters_and_arguments|arguments]]) that can be passed on to certain templates in order for them to work in different ways. Templates can either use no parameters, a fixed number of parameters, or a variable number of parameters. The number of parameters a template can use is from one upwards. The exact syntax for using parameters with templates can vary greatly, depending on the actual template being used. But, for an example template titled Template:Pagename, which happened to use three parameters, the general form would be: <syntaxhighlight lang="wikitext" inline>{{Pagename|parameter1|parameter2|parameter3}}</syntaxhighlight> {{shortcut|WP:UNNAMED|WP:POSPARAM|WP:POSITIONAL}} with each parameter being substituted with a <code>value</code>, or a <code>parameter name=value</code>, when used in practice. Notice that each parameter is separated with a [[vertical bar]]. Parameters that take the form <code>value</code> are called ''unnamed'' or ''positional parameters.'' Parameters that take the form <code>parameter name=value</code> are called ''named parameters''. With unnamed parameters, the first, second, third etc. parameters are equivalent to parameters '1', '2', '3' etc. in [[Wikipedia:Template_documentation|template documentation.]] Unnamed parameters must be in the correct order, and best placed before named parameters. An example of the syntax using the [[Template:Collapse top]]: <syntaxhighlight lang="wikitext" inline>{{Collapse top|This is the title text|This is a custom warning line|left=true}}</syntaxhighlight> In this particular example, three parameters are used, but Template:Collapse top can actually use a variable number of parameters. <code>This is the title text</code> and <code>This is a custom warning line</code> are the values of unnamed parameters '1' and '2'; and <code>true</code> is the value of the named parameter <code>left</code>. For more details, see [[Help:Template]]. Also, see [[Wikipedia:Template index]] for a list of links to available Main Namespace related templates (usually for encyclopedic articles); and other Namespace related templates (usually for non-article pages); there is also a search function. Template parameters are also used in the [[#Parametrization method|parametrization method]] of selective transclusion. ===Substitution=== [[wikipedia:Help:Substitution|Substitution]] has a similar double curly-bracket syntax, and its action is similar to transclusion. When you preview a page with substitution wikitext in it, its action is identical to transclusion. But when you save a page with substitution wikitext in it, it differs in that it substitutes that wikitext with the actual wikitext of the template. For example, when <syntaxhighlight lang="wikitext" inline>{{subst:Like}}</syntaxhighlight> is saved, it would substitute that wikitext with the actual wikitext from the [[Template:Like]]. In practice, the main difference that this makes is that if an update happened to the wikitext of the Template:Like, it would not update any pages where <syntaxhighlight lang="wikitext" inline>{{subst:Like}}</syntaxhighlight> had already been saved. ===Magic words=== [[wikipedia:Help:Magic words|Magic words]] are not examples of transclusion. But some have a similar double curly-bracket syntax and action to transclusion. For example, <syntaxhighlight lang="wikitext" inline>{{FULLPAGENAME}}</syntaxhighlight> renders the [[Wikipedia:Page name|Fullpagename]] of any Wikipedia page. Like templates, some magic words can also take parameters, which are separated using a colon (:); for example <syntaxhighlight lang="wikitext" inline>{{FULLPAGENAME:value}}</syntaxhighlight>. Templates do exist for some magic words, for example [[Template:FULLPAGENAME]]; but these just invoke the related magic word if passing parameters using a vertical bar (|); for example like <syntaxhighlight lang="wikitext" inline>{{FULLPAGENAME|value}}</syntaxhighlight>. But magic words parameters are best passed directly by using a colon, for example like <syntaxhighlight lang="wikitext" inline>{{FULLPAGENAME:value}}</syntaxhighlight>, which bypasses any templates. ===Transclusion modifiers=== As discussed above, with the example <syntaxhighlight lang="wikitext" inline>{{subst:Like}}</syntaxhighlight>, the <code>subst:</code> code alters the transclusion to substitution. This is a ''transclusion modifier'', a type of specialist magic word for altering transclusion in some manner. Another example is <syntaxhighlight lang="wikitext" inline>{{:Notability}}</syntaxhighlight>, where the <code>:</code> (colon character) forces transclusion to the main namespace. There are additional transclusion modifiers such as <code>safesubst:</code>, <code>int:</code>, <code>msg:</code>, <code>msgnw:</code>, and <code>raw:</code>. For more details on their usage, see {{slink|mw:wikipedia:Help:Magic words#Transclusion modifiers}}. Also see the modified commands <code>#section:</code>, <code>#section-x:</code> and <code>#section-h:</code> used for [[Help:Labeled section transclusion|labeled section transclusion]].
Summary:
Please note that all contributions to Red Letter Media Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
RLMWiki:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Toggle limited content width