Template

Template:Introduction to Transclusion

From Joomla! Documentation

From a technical standpoint one of the main reasons that we are using MediaWiki for this project is that it supports modular documentation in a natural way through a mechanism called "transclusion". It is important that contributors to this project understand the basic idea behind transclusion as it is the key to understanding how documents are assembled in the wiki from the database of available source modules.

In MediaWiki a conventional link to another page in the wiki is declared by typing something like this into the editor: [[Template:Example of a transcluded page]]. Such a link is shown below. The "Template:" prefix is used here because this is the default namespace for transcluded pages; something we'll come back to in a minute. The link should appear in blue to indicate that the page being linked to actually exists (it would be red otherwise).

Template:Example of a transcluded page

But if instead of using square brackets, you use curly brackets instead, then instead of seeing a blue link you will see the contents of the page being linked to embedded in this page. For example, the next paragraph is actually located in the page called "Example of a transcluded page", and is being included here because below is a link that looks like this: {{Example of a transcluded page}}.

If the page being linked to using transclusion does not exist then the link will appear in red, just like a normal link. If you click on it you will take to the editor where you can create the page.

Click on the "edit" tab for this page to see how it works.

Now for technical reasons I won't go into here, we don't want the transcluded pages for the template tutorials to be stored in MediaWiki's Template namespace. Instead we want them in the Main namespace and to do this the "Template:" prefix is dropped when creating a normal link and a ":" is prefixed to the page name for a transclusion link. So a conventional link will look like this in the editor:

[[Example of a transcluded page]]

and a transclusion link will look like this:

{{:Example of a transcluded page}}


TO BE CONTINUED