Check out my first novel, midnight's simulacra!

Help:Multiple-instance templates

From dankwiki
Revision as of 07:32, 17 May 2024 by MediaWiki>Rand(1,2022)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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.

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:

See also