Latest Neocron News and Information

  • New test server patch #563 has been released to Vedeena

Difference between revisions of "Neocron Wiki:Transclusion"

From Neocron Wiki
Jump to: navigation, search
m (New page: '''Transclusion''' is generally the inclusion of the content of a document into another document by reference. In the Wikipedian context, it is the use of the template functionality o...)
 
m
 
Line 1: Line 1:
'''[[Transclusion]]''' is generally the inclusion of the content of a document into another document by reference.  In the Wikipedian context, it is the use of the template functionality of [[MediaWiki]] to include the same content in multiple documents without having to edit those documents separately.
+
'''[[Project:Transclusion|Transclusion]]''' is generally the inclusion of the content of a document into another document by reference.  In the Wiki context, it is the use of the template functionality of MediaWiki to include the same content in multiple documents without having to edit those documents separately.
  
 
== How transclusion works ==
 
== How transclusion works ==
  
<div style="{{divstylenone}} float:left; width:258px;">
+
<div style="float:left; width:258px;">
 
[[Image:Transclusion-simple.png|left]]
 
[[Image:Transclusion-simple.png|left]]
 
</div>  
 
</div>  
  
<div class="boilerplate metadata" id="Template syntax" style="border: 1px solid rgb(0, 153, 0); margin: 0.5em; padding: 0.5em; background-color: rgb(204, 255, 204); float: right; width: 35%; color: grey; "><center><b>Template syntax</b></center>
+
<div style="border: 1px solid rgb(0, 153, 0); margin: 0.5em; padding: 0.5em; background-color: rgb(204, 255, 204); float: right; width: 35%; color: grey; "><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 Main article namespace (e.g., "[[Map]]"), you must put a colon (:) in front of the name, thus: <code><nowiki>{{:Map}}</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 the Template namespace (e.g., "[[Template:Deletion]]"), just use the name itself, alone, thus: <code><nowiki>{{Deletion}}</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>
+
If the source is in any other namespace (e.g., "[[User:Delphi]"), you must use the full name, including the namespace, thus: <code><nowiki>{{User:Delphi}}</nowiki></code>
 
</div>
 
</div>
  
Line 24: Line 24:
 
{{clear}}
 
{{clear}}
  
<div style="{{divstylenone}} float:left; width:544px;">
+
<div style="float:left; width:544px;">
 
[[Image:TC-mult.PNG|left]]
 
[[Image:TC-mult.PNG|left]]
 
[[Image:TC-mult-twit.PNG|left]]
 
[[Image:TC-mult-twit.PNG|left]]
Line 33: Line 33:
 
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 the message should appear. When the template is edited, all the target-pages are edited too.
 
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 the message should appear. When the template is edited, all the target-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.
+
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}}
 
{{clear}}
Line 40: Line 40:
 
==Partial transclusion==
 
==Partial transclusion==
 
By using "noinclude", "onlyinclude" and "includeonly" markup, it is possible to transclude part of a page rather than all of it. Such partial transclusions can also be achieved by transcluding from other pages such as subpages. It is often useful not to transclude some information, such as template documentation.  
 
By using "noinclude", "onlyinclude" and "includeonly" markup, it is possible to transclude part of a page rather than all of it. Such partial transclusions can also be achieved by transcluding from other pages such as subpages. It is often useful not to transclude some information, such as template documentation.  
 
For an example of how this technique can be applied to simplify the creation of [[WP:SS|summary articles]], see [[Pathology]], which consists of a collection of transcluded [[WP:LEAD|lead paragraphs]] from several main articles.
 
  
 
===Transclusion markup===
 
===Transclusion markup===
Line 50: Line 48:
  
 
===Subpages===
 
===Subpages===
One can cut and paste the text to be transcluded into a [[Wikipedia:Subpages|subpage]], then use the name of the subpage in the transclusion template. This approach can only be used with subpages from User, Talk or Wikipedia pages; currently, subpages [[Wikipedia:Subpages#Articles do not have sub-pages (main namespace)|cannot be created from main article pages]].  
+
One can cut and paste the text to be transcluded into a subpage, then use the name of the subpage in the transclusion template. This approach can only be used with subpages from User, Talk or Wikipedia pages; currently, subpages cannot be created from main article pages.  
  
Example: you want to discuss the deletion and redirecting of [[Pussycat]] to [[Cat]]. First, create the subpage [[Talk:Pussycat/Let's delete Pussycat!]], write your comment into it, then transclude it in [[Talk:Pussycat]] and [[Talk:Cat]] using the template '''<nowiki>{{:Talk:Pussycat/Let's delete Pussycat!}}</nowiki>''' (note the colon before the page name). Comments posted in either talk pages will be shown in both.
+
Example: you want to discuss the deletion and redirecting of [[R.P.O.S.]] to [[RPOS]]. First, create the subpage [[Talk:R.P.O.S./Let's delete R.P.O.S.!]], write your comment into it, then transclude it in [[Talk:R.P.O.S.]] and [[Talk:RPOS]] using the template '''<nowiki>{{:Talk:R.P.O.S./Let's delete R.P.O.S.!}}</nowiki>''' (note the colon before the page name). Comments posted in either talk pages will be shown in both.

Latest revision as of 22:48, 1 August 2008

Transclusion is generally the inclusion of the content of a document into another document by reference. In the Wiki context, it is the use of the template functionality of MediaWiki to include the same content in multiple documents without having to edit those documents separately.

How transclusion works

Transclusion-simple.png
Template syntax

If the source is in the Main article namespace (e.g., "Map"), you must put a colon (:) in front of the name, thus: {{:Map}}

If the source is in the Template namespace (e.g., "Template:Deletion"), just use the name itself, alone, thus: {{Deletion}}

If the source is in any other namespace (e.g., "[[User:Delphi]"), you must use the full name, including the namespace, thus: {{User:Delphi}}

To transclude any source page (within a single MediaWiki project, such as en:Wikipedia) within another target page, include the following code:

{{SOMEPAGE}}

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.

TC-mult.PNG
TC-mult-twit.PNG

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 the message should appear. When the template is edited, all the target-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.


Partial transclusion

By using "noinclude", "onlyinclude" and "includeonly" markup, it is possible to transclude part of a page rather than all of it. Such partial transclusions can also be achieved by transcluding from other pages such as subpages. It is often useful not to transclude some information, such as template documentation.

Transclusion markup

  • noinclude. The markup <noinclude>...</noinclude> means that the text between the tags will not be transcluded onto another page, but will only appear on the page itself. This is useful for documentation.
  • includeonly. The markup <includeonly>...</includeonly> means that the text between the tags will only be used when the page is transcluded onto another page, and will not appear on the page itself. This can be useful, for example, for adding categories to pages transcluding a template, without adding the template itself to these categories.
  • onlyinclude. The markup <onlyinclude>...</onlyinclude> indicates that only text surrounded by "onlyinclude" markup should be transcluded onto another page. This is the most subtle of the partial transclusion tags because it often overrules the others. If there is at least one pair of "onlyinclude" tags on a page, then whenever this page is transcluded, it is only the material within the "onlyinclude" tags which gets transcluded. There can be several such sections, and within each such section, some material might be further excluded by "noinclude" tags, and might also be surrounded by "includeonly" tags so that it does not appear on the original page itself. But material outside the "onlyinclude" tags will be ignored when the page is transcluded onto another page. This can be useful, for example, to repeat a small part of one page on a second one: just surround the small part by onlyinclude tags, and transclude it onto the second page.

Subpages

One can cut and paste the text to be transcluded into a subpage, then use the name of the subpage in the transclusion template. This approach can only be used with subpages from User, Talk or Wikipedia pages; currently, subpages cannot be created from main article pages.

Example: you want to discuss the deletion and redirecting of R.P.O.S. to RPOS. First, create the subpage Talk:R.P.O.S./Let's delete R.P.O.S.!, write your comment into it, then transclude it in Talk:R.P.O.S. and Talk:RPOS using the template {{:Talk:R.P.O.S./Let's delete R.P.O.S.!}} (note the colon before the page name). Comments posted in either talk pages will be shown in both.