Transclusion

From mw.mh370.wiki
Jump to navigation Jump to search

A Guide to Using MediaWiki in a Hosted Environment

An instructional website by the developer of mh370wiki.net - a MediaWiki site about Malaysia Airlines Flight MH370.


Transclusion

"In computer science, transclusion is the inclusion of part or all of an electronic document into one or more other documents by reference via hypertext."[1]

Ted Nelson coined the term Transclusion, as well as hypertext and hypermedia", in his 1982 book Literary Machines.[2]

Transclusion in MediaWiki

Transclusion is a very useful feature in MediaWiki. A source page can be transcluded into another page by enclosing the page name in curly brackets like this:-

{{:SourcePageName}}

If the source page is in the Main namespace then the page name should be preceded by the colon (:) as shown above.

If the colon is omitted then MediaWiki will search the Template Namespace by default.

If the source page is in a custom namespace then the Namespace prefix must be inserted so the source can be found:-

{{Snippets:Some Content}}

As this is an instructional site, there is actually some content in that page, including a link to itself. Using the above syntax yields this result (which I have indented):-

Content Heading

This is some content in the Snippets Namespace.

Here is a link to this page: Some Content.

Partial Transclusion

The above examples would transclude the entire content of the source page or template. To prevent that, or to ensure that only a specific section is transcluded, it is necessary to surround the sections to be included or excluded with special markup. MediaWiki provides three options. Despite using transclusion often, and for over a decade, I sometimes need to be reminded of the difference between only include and includeonly, so in my on-line Manual on the mh370wiki.net I have a page containing the following, and when I want to create a transcludable section I just copy the relevant section, below:-

<!-- Content visible on the source page AND visible when transcluded onto a different page. -->
<onlyinclude>

‎</onlyinclude>
<!-- Content not visible on the source page and visible ONLY when transcluded onto a different page. -->
<includeonly>

</includeonly>
<!-- Content is visible ONLY on source page and can NOT be transcluded onto another page -->
<noinclude>

‎</noinclude>


Articles which relate to transclusion in MediaWiki

Articles which relate to transclusion in MediaWiki are included in Category:Transclusion.

The CategoryTree extension enables a listing of relevant sub-categories and pages:-




References

  1. Source: Wikipedia Transclusion
  2. Source: MediaWiki Transclusion