Help:Transclusion
On Vikidia, an transclusion is the act of inserting the content of one page into another page. Here, we explain how it works. There are two types of transclusion: templates and regular pages. There are also tags that assist with transclusion. Transclusion uses the characters {{ and }}.
Including Templates[change source]
A template is used to insert something into a page that would take a long time to recreate each time. It also helps keep the page's code clean and organized. For example:
{{star article}}
is shorter and faster to insert than this:
{{Meta banner
| background-color = #FFFFD4
| border-color = #FFCC00
| icon = Star icon.png
| title = Star article
| text = This article has been selected as a ''[[Vikidia:Star article|star article]]''! You can view its voting page [[Vikidia:Super article/Election/{{BASEPAGENAME}}|here]].
}}
Templates are located in the "Template:" namespace, meaning their names all begin with "Template:". But fortunately, you don't need to include "Template:"; just use the name (don't write "{{Template:Star article}}"—even though that works—but rather "{{star article}}")! And sometimes, to help create templates, we even use templates to make templates! Look at the code for {{star article}} (it's shown just above)—we're using the {{Meta banner}} template to help with the creation and readability of the code!
Parameters[change source]
Some templates have parameters that need to be filled in. To do this, simply write: {{Template|Parameter 1|Parameter 2...}}
Including a page[change source]
It's also possible to include a page. Simply use {{Page name}}. Be careful, however: if the page you want to include has the same name as a template, the software will include the template instead of the page! Note that including a page is generally not very useful, except for certain subpages.
Transclusion Help[change source]
On some template pages, there is the template itself—which will be included—as well as documentation explaining how to use the template. But how can you place the documentation on the same page without it also being included when the template is inserted? There are tags for this purpose. To prevent a paragraph from being included, enclose it in the following:
<noinclude>Text not to be included</noinclude>
Conversely, if you want something to appear when it's included elsewhere but not be visible on its original page, simply use the following tags:
<includeonly>Text</includeonly>
Also, if you want to include a template but insert the entire code, simply add "SUBST:" before the template name: {{SUBST:Template}}
There are also codes that resemble transclusions but are not, and are used to set conditions. In this case, there is a # in front of it: {{#if}}.
There are also "magic" transclusions. They can be recognized because they are in uppercase, for example: {{FULLPAGENAME}}, which inserts the full name of the page.