Thread:RR3 Michael P/@comment-27006659-20170319151020/@comment-25956839-20170507185351

Some information on how to design templates

Here are some help articles explaining templates:


 * w:Help:Templates
 * w:Help:Template types
 * w:Help:Template parameters

Start with a basic template, used to car information on RR3 Wiki:Pages That Need Editing:

...

The heading to the table is:
 * Template:H/CarComp

The Data is:
 * Template:R/CarComp

The data is repeated until it has an End template
 * Template:End

When combined the templates make a table, with repeating input data. This template also add a variable, this is the No. starting with 0 and adding 1 each time the template is called.

This template takes 8 default parser spilt up by a pipe | and two optional named parser, ALT and NEW. If a parser is not present a default value is used:

= Model - if blank default is ? = Make - if blank default is ? = Alternative car Name (With Italic Formatting) = Introduction (Infobox Car) - if blank default is OK = Availability - if blank default is OK = Characteristics (T stats) - if blank default is OK = Upgrades (T upgrades) - if blank default is OK = Trivia (optional) - if blank default is OK = Info Boxes (Manufacturer) - if blank default is None = Y (New cars are red), the default value for - is also New.

This makes templates perfect for creating tables with repeating data. Each time the template is called, with some data, a row of a table is returned, with the data filled in, and formatted, in the correct cell. If a table can be designed to display repeating data, then a template can be used.

There is a maximum limit to the size of a table called this way. 5,000 nodes, so the all series database has to be displayed as a table.

The best way to experiment with templates is in your sandbox. E.G. see http://rr3.wikia.com/wiki/User:RR3_Michael_P/Sandbox27?action=edit

|- ! style="background-color: #56758D; border-right: 1px solid transparent;" data-sort-value=" " | ... ....
 * h }} |?}}

....

Don't worry about the complexity of this template, the point is the template is inside:

...

The Data can then call the template, from the same sandbox page:

Using this method a template can be designed and tested in the same sandbox, once the template is updated and published, in the sandbox, click the clock (in the top right of the wiki page), to purge the page and re-load the template, ready for the data to be tested.

This is a basic overview of how to design templates, please try for yourself. Start with a table design, then convert the table into a template. Once that works if statements can be added to error trap missing or incorrect data. It is also possible to call another template from inside a template, for example to format a number.

I would recommend to start with a basic table / template and work up. It is very easy for a missing closed bracket to break a template, by working up step by step. Any edits that fail can be easily reverted, by checking the page history and editing the previous version. Variables can also be added e.g. to calculate totals.

Any templates you want to use or change, on the Wiki needs to be approved by an Admin.

I hope this helps.

RR3 Michael P (talk) 18:53, May 7, 2017 (UTC)