Check out my first novel, midnight's simulacra!
Help:Multiple-instance templates
Multiple-instance templates refer to the use of a series of instances of the same (wiki) template on a single wiki page, usually with unique data assigned to each instance. For instance, instances of a template may be used to list the contacts of a company, the ingredients of a recipe, the stories in a book, etc. In this way, you can present items of the same type in a uniform manner and streamline structured data so that they can be stored in the database.
The term is typically used in the context of managing such a list of template instances by way of a form (see the form extensions below) as well as itemising data to be stored in the database (see the data storage extensions below).
Structurally, multiple-instance templates can be either top-level templates or children of a parent template. A child template is an instance of a template assigned to a parameter of the parent template. A top-level template is not nested in this way and may or may not behave as a parent template for one or multiple child templates. Deeper levels of nesting templates are not impossible, but lack support in form extensions.
Example
The ingredients of some recipe for salad :
{{Recipe |Title=My favourite salad |Ingredients={{Ingredient |Item=Romaine lettuce |Quantity=Four leaves. |Preparation=Torn. }}{{Ingredient |Item=Radish |Quantity=Six radishes. |Preparation=Chopped. }}{{Ingredient |Item=Tomato |Quantity=2 tomatoes. |Preparation=Chopped. }}{{Ingredient |Item=Licame |Quantity=A small one. |Preparation=Peeled and julienned. }} }}
(etc.)
Form extensions
A number of extensions are available that let you use a form to manage template instances more easily.
- Extension:Page Forms: see especially this help page. The term 'multiple-instance templates' was likely coined for this extension.
- Extension:FlexForm: offers similar support. See especially this help page.
Data storage extensions
Template instances can be used as containers for structured data. The following extensions offer parser functions that can be used in a template to store data:
- Extension:Semantic MediaWiki (SMW) - offers the
#subobject
parser function for self-contained units of property-value pairs as well as a data type called Record. - Extension:Cargo - offers
#cargo_declare
and#cargo_store
, which can be used in a way similar to SMW's subobjects.