<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://mwiki.costasano.club/index.php?action=history&amp;feed=atom&amp;title=ICT%3ATemplate_Inclusion_and_Transclusion_Guide</id>
	<title>ICT:Template Inclusion and Transclusion Guide - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://mwiki.costasano.club/index.php?action=history&amp;feed=atom&amp;title=ICT%3ATemplate_Inclusion_and_Transclusion_Guide"/>
	<link rel="alternate" type="text/html" href="https://mwiki.costasano.club/index.php?title=ICT:Template_Inclusion_and_Transclusion_Guide&amp;action=history"/>
	<updated>2026-07-22T23:27:27Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.45.1</generator>
	<entry>
		<id>https://mwiki.costasano.club/index.php?title=ICT:Template_Inclusion_and_Transclusion_Guide&amp;diff=239&amp;oldid=prev</id>
		<title>Mngr: Created page with &quot;= Template Inclusion and Transclusion Guide =  == Purpose == This page explains how MediaWiki controls what parts of a template are:  * visible on the template page itself * visible when the template is used inside other pages (transcluded)  Understanding this mechanism is essential when building:  * Cargo storage templates * Page Forms templates * system templates  Incorrect usage can cause: * wrong Cargo rows * unwanted text on pages * confusing behaviour  ----  == Cor...&quot;</title>
		<link rel="alternate" type="text/html" href="https://mwiki.costasano.club/index.php?title=ICT:Template_Inclusion_and_Transclusion_Guide&amp;diff=239&amp;oldid=prev"/>
		<updated>2026-01-29T16:34:30Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;= Template Inclusion and Transclusion Guide =  == Purpose == This page explains how MediaWiki controls what parts of a template are:  * visible on the template page itself * visible when the template is used inside other pages (transcluded)  Understanding this mechanism is essential when building:  * Cargo storage templates * Page Forms templates * system templates  Incorrect usage can cause: * wrong Cargo rows * unwanted text on pages * confusing behaviour  ----  == Cor...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;= Template Inclusion and Transclusion Guide =&lt;br /&gt;
&lt;br /&gt;
== Purpose ==&lt;br /&gt;
This page explains how MediaWiki controls what parts of a template are:&lt;br /&gt;
&lt;br /&gt;
* visible on the template page itself&lt;br /&gt;
* visible when the template is used inside other pages (transcluded)&lt;br /&gt;
&lt;br /&gt;
Understanding this mechanism is essential when building:&lt;br /&gt;
&lt;br /&gt;
* Cargo storage templates&lt;br /&gt;
* Page Forms templates&lt;br /&gt;
* system templates&lt;br /&gt;
&lt;br /&gt;
Incorrect usage can cause:&lt;br /&gt;
* wrong Cargo rows&lt;br /&gt;
* unwanted text on pages&lt;br /&gt;
* confusing behaviour&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
== Core concept: Transclusion ==&lt;br /&gt;
&lt;br /&gt;
=== What is transclusion? ===&lt;br /&gt;
&lt;br /&gt;
When a page contains:&lt;br /&gt;
&lt;br /&gt;
  {{DigitalAsset}}&lt;br /&gt;
&lt;br /&gt;
MediaWiki does NOT copy text.&lt;br /&gt;
&lt;br /&gt;
Instead it:&lt;br /&gt;
&lt;br /&gt;
# loads Template:DigitalAsset&lt;br /&gt;
# inserts its content dynamically&lt;br /&gt;
# renders the result&lt;br /&gt;
&lt;br /&gt;
This process is called &amp;#039;&amp;#039;&amp;#039;transclusion&amp;#039;&amp;#039;&amp;#039;.&lt;br /&gt;
&lt;br /&gt;
So a template has two different contexts:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Context !! Meaning&lt;br /&gt;
|-&lt;br /&gt;
| Template page itself || Template:DigitalAsset is opened directly&lt;br /&gt;
|-&lt;br /&gt;
| Transcluded page || The template is used inside another page&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
MediaWiki allows us to control what appears in each context.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
== The three inclusion modes ==&lt;br /&gt;
&lt;br /&gt;
=== 1. &amp;amp;lt;noinclude&amp;amp;gt; ===&lt;br /&gt;
&lt;br /&gt;
Visible only on the template page itself.  &lt;br /&gt;
Hidden when the template is transcluded.&lt;br /&gt;
&lt;br /&gt;
Use for:&lt;br /&gt;
* documentation&lt;br /&gt;
* instructions&lt;br /&gt;
* comments for editors&lt;br /&gt;
* maintenance notes&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;noinclude&amp;gt;&lt;br /&gt;
This template stores DigitalAssets in Cargo.&lt;br /&gt;
Do not edit manually.&lt;br /&gt;
&amp;lt;/noinclude&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Visible on:&lt;br /&gt;
 Template:DigitalAsset&lt;br /&gt;
&lt;br /&gt;
Not visible on:&lt;br /&gt;
 DA:0001&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
=== 2. &amp;amp;lt;includeonly&amp;amp;gt; ===&lt;br /&gt;
&lt;br /&gt;
Visible only when transcluded.  &lt;br /&gt;
Hidden on the template page itself.&lt;br /&gt;
&lt;br /&gt;
Use for:&lt;br /&gt;
* Cargo storage&lt;br /&gt;
* categories&lt;br /&gt;
* logic&lt;br /&gt;
* anything that should affect real data pages&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;includeonly&amp;gt;&lt;br /&gt;
{{#cargo_store: ... }}&lt;br /&gt;
&amp;lt;/includeonly&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Runs on:&lt;br /&gt;
 DA:0001&lt;br /&gt;
&lt;br /&gt;
Does NOT run on:&lt;br /&gt;
 Template:DigitalAsset&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
=== 3. No tags ===&lt;br /&gt;
&lt;br /&gt;
Content without tags appears everywhere.&lt;br /&gt;
&lt;br /&gt;
Visible:&lt;br /&gt;
* on template page&lt;br /&gt;
* on all pages using the template&lt;br /&gt;
&lt;br /&gt;
Usually not desired for system templates.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
== Why this matters for Cargo (very important) ==&lt;br /&gt;
&lt;br /&gt;
Cargo executes:&lt;br /&gt;
&lt;br /&gt;
  {{#cargo_store:}}&lt;br /&gt;
&lt;br /&gt;
whenever the template is rendered.&lt;br /&gt;
&lt;br /&gt;
If you do NOT use &amp;amp;lt;includeonly&amp;amp;gt;:&lt;br /&gt;
&lt;br /&gt;
Opening:&lt;br /&gt;
 Template:DigitalAsset&lt;br /&gt;
&lt;br /&gt;
would also execute cargo_store.&lt;br /&gt;
&lt;br /&gt;
Result:&lt;br /&gt;
* unwanted database rows&lt;br /&gt;
* template page stored as data&lt;br /&gt;
* corrupted tables&lt;br /&gt;
&lt;br /&gt;
Therefore:&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;All #cargo_store calls MUST be inside &amp;amp;lt;includeonly&amp;amp;gt;.&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
== Standard professional structure for Cargo templates ==&lt;br /&gt;
&lt;br /&gt;
Recommended pattern:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;noinclude&amp;gt;&lt;br /&gt;
Documentation for administrators and editors.&lt;br /&gt;
Explain fields and usage here.&lt;br /&gt;
&amp;lt;/noinclude&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;includeonly&amp;gt;&lt;br /&gt;
{{#cargo_store:&lt;br /&gt;
 _table=DigitalAssets&lt;br /&gt;
 |id={{{id|}}}&lt;br /&gt;
 |file_id={{{file_id|}}}&lt;br /&gt;
}}&lt;br /&gt;
&amp;lt;/includeonly&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Meaning:&lt;br /&gt;
&lt;br /&gt;
* documentation only visible to editors&lt;br /&gt;
* storage only happens on real pages&lt;br /&gt;
&lt;br /&gt;
Clean separation of concerns.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
== Mental model ==&lt;br /&gt;
&lt;br /&gt;
Think of it like visibility scopes:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Tag !! Visible to&lt;br /&gt;
|-&lt;br /&gt;
| noinclude || template editors only&lt;br /&gt;
|-&lt;br /&gt;
| includeonly || pages using the template only&lt;br /&gt;
|-&lt;br /&gt;
| none || everyone&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
== Practical rules for this project ==&lt;br /&gt;
&lt;br /&gt;
=== Cargo / data templates ===&lt;br /&gt;
Use:&lt;br /&gt;
* includeonly for all functional logic&lt;br /&gt;
* noinclude for documentation&lt;br /&gt;
&lt;br /&gt;
=== Documentation templates ===&lt;br /&gt;
Usually no special tags needed&lt;br /&gt;
&lt;br /&gt;
=== When unsure ===&lt;br /&gt;
Ask:&lt;br /&gt;
&amp;quot;Should this appear on the template page or only on real pages?&amp;quot;&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
== Common mistakes ==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Mistake !! Result&lt;br /&gt;
|-&lt;br /&gt;
| cargo_store outside includeonly || unwanted rows created&lt;br /&gt;
|-&lt;br /&gt;
| documentation without noinclude || text appears on every page&lt;br /&gt;
|-&lt;br /&gt;
| mixing display and storage logic || hard to debug behaviour&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
== Final advice ==&lt;br /&gt;
&lt;br /&gt;
Templates are half content, half code.&lt;br /&gt;
&lt;br /&gt;
Treat them like small programs:&lt;br /&gt;
&lt;br /&gt;
* keep logic minimal&lt;br /&gt;
* keep behaviour explicit&lt;br /&gt;
* separate documentation from execution&lt;br /&gt;
&lt;br /&gt;
Clarity prevents subtle bugs.&lt;/div&gt;</summary>
		<author><name>Mngr</name></author>
	</entry>
</feed>