User:Ferretwings/Sandbox/DPL/Surrogate templates/dpl

From Terraria Wiki
Jump to navigation Jump to search
== Combining multiple templates into one ==
The dpl clause: "include = {template-1¦combined-template}, {template-2¦combined-template} | mode=userformat"

For this example: "include = {infobox wrapper¦/dpl}, {item infobox¦/dpl} | mode=userformat"
(see User:Ferretwings/Sandbox/DPL/Surrogate templates for the full dpl statement)

In most situations, the info will be displayed as the last template is processed.
Any info that is not located in the last template listed will need to be stored into dpl variables.

To test which template is being processed, test for unique fields only found on each template
(this can be problematic if the called template contains only optional parameters).

If combining many templates, store all info into dpl variables, and use a unique field found in the last called template to trigger the display.

The following dpl display format combines fields from Item infobox and Infobox wrapper; this particular format is only an example, as such a list wouldn't be very useful. Presence of the {{{name|}}} or {{{namesub|}}} field will trigger the actual display.
<!--

// Display template info and dpl variables.
   Infobox wrapper has only optional fields, so testing for non-Infobox wrapper field.
-->{{#if:{{{name|{{{namesub|}}}}}}|<!--

// only display if there are named infoboxes -->
{{!}}-
{{!}} [[{{{%PAGE%}}}]] {{!!}} {{{name|{{{namesub|}}}}}} {{!!}} {{#dplvar:dir}}
{{!}}-
|<!--else

// Store dpl variables.
// id and Set are unique to Item infobox, and NOT found in Infobox wrapper
-->{{#if:{{{id|{{#ifeq:{{{type2|}}}|Set|y}}}}}<!--
   -->|<!-- don't process --
   -->|{{#dplvar:set|dir|{{{direction|undefined}}}}}}}}}