Help:Transclusion: Difference between revisions

Jump to navigation Jump to search
no edit summary
No edit summary
No edit summary
Line 6: Line 6:
{{Broader|Transclusion}}
{{Broader|Transclusion}}
{{Information page|H:TRANS|SW:TRANS}}
{{Information page|H:TRANS|SW:TRANS}}
'''Transclusion''' means the inclusion of the content of one document within another document by [[Reference (computer science)|reference]].  In Stiles.casa Wiki transclusion, the [[MediaWiki]] software will refer to the content of one page, the [[SW:template|template]], for inclusion into the content of any other page, the target page.  Similar to the way any [[wp:page name|page name]] can become a link by placing its name in double square brackets, any page name can become a template by placing it in double curly braces, '''<code><nowiki>{{</nowiki>''Namespace'':''[[SW:Page name|Pagename]]''}}</code>'''. Changes made to the template are then automatically reflected on all pages into which that page has been transcluded (though a [[Stiles.casa Wiki:Purge|purge]] may sometimes be necessary).
'''Transclusion''' means the inclusion of the content of one document within another document by [[Reference (computer science)|reference]].  In Stiles.casa Wiki transclusion, the [[MediaWiki]] software will refer to the content of one page, the [[SW:template|template]], for inclusion into the content of any other page, the target page.  Similar to the way any [[sw:page name|page name]] can become a link by placing its name in double square brackets, any page name can become a template by placing it in double curly braces, '''<code><nowiki>{{</nowiki>''Namespace'':''[[SW:Page name|Pagename]]''}}</code>'''. Changes made to the template are then automatically reflected on all pages into which that page has been transcluded (though a [[Stiles.casa Wiki:Purge|purge]] may sometimes be necessary).


If the template's [[SW:page name|page name]] does not begin with a namespace, it is assumed to be in the Template namespace. To refer to a page in the "Main" (article) namespace, it is necessary to prefix it with a colon (''':'''). Examples:
If the template's [[SW:page name|page name]] does not begin with a namespace, it is assumed to be in the Template namespace. To refer to a page in the "Main" (article) namespace, it is necessary to prefix it with a colon (''':'''). Examples:
Line 14: Line 14:
* '''<code><nowiki>{{SW:Assume good faith}}</nowiki></code>''' will transclude from the page [[Stiles.casa Wiki:Assume good faith]]
* '''<code><nowiki>{{SW:Assume good faith}}</nowiki></code>''' will transclude from the page [[Stiles.casa Wiki:Assume good faith]]


What will transclude from a page can be controlled with the tags <nowiki><noinclude>, <onlyinclude> and <includeonly></nowiki> placed in the source page wikitext. (See [[#Markup|markup]], below.)  The use of tags enables the template to transclude partially, otherwise the double curly braces will always transclude all content.  For ''selective'' transclusion the <nowiki><includeonly></nowiki> parts of the template are named (with the help of [[wp:parser functions|parser functions]]) and that template is then called with the [[Help:Template#Parameters|parameter]] <code>transcludesection=''name''</code>.
What will transclude from a page can be controlled with the tags <nowiki><noinclude>, <onlyinclude> and <includeonly></nowiki> placed in the source page wikitext. (See [[#Markup|markup]], below.)  The use of tags enables the template to transclude partially, otherwise the double curly braces will always transclude all content.  For ''selective'' transclusion the <nowiki><includeonly></nowiki> parts of the template are named (with the help of [[sw:parser functions|parser functions]]) and that template is then called with the [[Help:Template#Parameters|parameter]] <code>transcludesection=''name''</code>.


Transclusion events occur every time the page is ''loaded'', when the template is rendered. Another use of the same mechanism is a one-shot ''[[Help:substitution|substitution]]'' of the template call itself by its transcluded source page.  A template call <code><nowiki>{{</nowiki>''[[SW:page name#Namespace, pagename, and fullpagename|fullpagename]]''}}</code> with the "subst:" prefix <code><nowiki>{{</nowiki>subst:''fullpagename''}}</code> is transcluded once but never again, because the wikitext of that call is replaced (substituted) when its page is ''saved''.  What was a one-time template call becomes the actual wikitext of the template at the time of its call.
Transclusion events occur every time the page is ''loaded'', when the template is rendered. Another use of the same mechanism is a one-shot ''[[Help:substitution|substitution]]'' of the template call itself by its transcluded source page.  A template call <code><nowiki>{{</nowiki>''[[SW:page name#Namespace, pagename, and fullpagename|fullpagename]]''}}</code> with the "subst:" prefix <code><nowiki>{{</nowiki>subst:''fullpagename''}}</code> is transcluded once but never again, because the wikitext of that call is replaced (substituted) when its page is ''saved''.  What was a one-time template call becomes the actual wikitext of the template at the time of its call.
Line 122: Line 122:
For more information on the current template system, see [[Stiles.casa Wiki:Template namespace]].
For more information on the current template system, see [[Stiles.casa Wiki:Template namespace]].
<!-- saving a nice programming tutorial on template language 'til someone merges it somehwere
<!-- saving a nice programming tutorial on template language 'til someone merges it somehwere
Cpiral moved it to [[wp:template namespace#Sandbox_for_experiments]], 9/12/2012
Cpiral moved it to [[sw:template namespace#Sandbox_for_experiments]], 9/12/2012
-->
-->


Line 287: Line 287:
{{see also|Stiles.casa Wiki:Special pages#Miscellaneous}}
{{see also|Stiles.casa Wiki:Special pages#Miscellaneous}}


Some pages on [[Special:Specialpages]] can be transcluded, such as [[Special:Allpages]], [[Special:Prefixindex]], [[Special:Newfiles]], [[Special:Newpages]], [[Special:Recentchanges]] and [[Special:Recentchangeslinked]].
Some pages on [[Special:Specialpages]] can be transcluded, such as [[Special:Allpages]], [[Special:Prefixindex]], [[Special:Newfiles]], [[Special:Neswages]], [[Special:Recentchanges]] and [[Special:Recentchangeslinked]].
Samples:
Samples:
*<code><nowiki>{{Special:Allpages/General}}</nowiki></code> – a list of pages starting at "General".
*<code><nowiki>{{Special:Allpages/General}}</nowiki></code> – a list of pages starting at "General".
*<code><nowiki>{{Special:Prefixindex/General}}</nowiki></code> – a list of pages with prefix "General".
*<code><nowiki>{{Special:Prefixindex/General}}</nowiki></code> – a list of pages with prefix "General".
*<code><nowiki>{{Special:Newfiles/4}}</nowiki></code> – a gallery of the four most recently uploaded files.
*<code><nowiki>{{Special:Newfiles/4}}</nowiki></code> – a gallery of the four most recently uploaded files.
*<code><nowiki>{{Special:Newpages/5}}</nowiki></code> – a list of the five most recently created pages.
*<code><nowiki>{{Special:Neswages/5}}</nowiki></code> – a list of the five most recently created pages.
*<code><nowiki>{{Special:Recentchanges/5}}</nowiki></code> – the five most recent changes.
*<code><nowiki>{{Special:Recentchanges/5}}</nowiki></code> – the five most recent changes.
*<code><nowiki>{{Special:Recentchangeslinked/General}}</nowiki></code> – recent changes to the pages linked from "General".
*<code><nowiki>{{Special:Recentchangeslinked/General}}</nowiki></code> – recent changes to the pages linked from "General".
Line 304: Line 304:
*<code><nowiki>{{Special:Prefixindex/Jimbo Wales/|namespace=2|stripprefix=1}}</nowiki></code> – the subpages for [[User:Jimbo Wales]], but without the user page prefix.
*<code><nowiki>{{Special:Prefixindex/Jimbo Wales/|namespace=2|stripprefix=1}}</nowiki></code> – the subpages for [[User:Jimbo Wales]], but without the user page prefix.


''Note:'' Transcluding certain special pages (such as [[Special:Newpages]]) can change the [[Stiles.casa Wiki:Page name|displayed title]] of the page.
''Note:'' Transcluding certain special pages (such as [[Special:Neswages]]) can change the [[Stiles.casa Wiki:Page name|displayed title]] of the page.


==See also==
==See also==

Navigation menu