Help:Transclusion/How Transclusion Works: Difference between revisions

Content deleted Content added
hay
Line 1:
== How transclusion works ==
 
<div style="{{divstylenone}} float:left; width:258px;">
[[Image:TC-simple.png|left]]
</div>
 
<div class="boilerplate metadata" id="Template syntax" style="{{divstylegreen}} float: right; width: 35%; "><center><b>Template syntax</b></center>
 
If the source is in the Main article namespace (e.g., "[[Cat]]"), you must put a colon (:) in front of the name, thus: <code><nowiki>{{:Cat}}</nowiki></code>
 
If the source is in the Template namespace (e.g., "[[Template:Villagepumppages]]"), just use the name itself, alone, thus: <code><nowiki>{{Villagepumppages}}</nowiki></code>
 
If the source is in any other namespace (e.g., "[[User:Example]]"), you must use the full name, including the namespace, thus: <code><nowiki>{{User:Example}}</nowiki></code>
</div>
 
To '''transclude''' any '''source''' page (within a single MediaWiki project, such as en:Wikipedia) within another '''target''' page, include the following code:
 
<code><nowiki>{{SOMEPAGE}}</nowiki></code>
 
Whenever the target page '''A''' with this code is rendered, the engine will include ''in that place'' not the code itself, but the entire content of the source page '''B''', SOMEPAGE.
 
{{clear}}
 
<div style="{{divstylenone}} float:left; width:544px;">
[[Image:TC-mult.PNG|left]]
[[Image:TC-mult-twit.PNG|left]]
</div>
 
{{clear}}
 
For example, you might decide to place a welcome message on every newcomer's Talk Page. Transclusion creates a "live" link between the "template" page and the target page(s) upon which it appears. When the template is edited, all the other pages are edited too.
 
For example, you ''might'' decide to create a (template) page with your mailing address and include that template on not only your page, but all your friends' pages, too. When you move your [[television]] and couch to another apartment, you will ''change'' your address template, and automatically, that ''new information'' will appear on all your friends' pages.
 
{{clear}}