Template:Chembox/doc/Adding a parameter to Chembox
< Template:Chembox | doc
Jump to navigation
Jump to search
Revision as of 13:07, 4 March 2014 by imported>DePiep (Into separate page to reduce documentation complexity.)
| 40x40px | This template employs intricate features of template syntax.
You are encouraged to familiarise yourself with its setup and parser functions before editing the template. If your edit causes unexpected problems, please undo it quickly, as this template may appear on a large number of pages. You can conduct experiments, and should test all major changes, in either this template's sandbox, the general template sandbox, or your user space before changing anything here. |
To add a new parameter to the Chembox:
- Select the section the parameter has to go into, and choose a unique parameter name in that section.
- Open the section template for editing.
- In the very first if-statement, add "{{{Yourparametername|}}}" to the list, this will make sure that when the parameter is supplied, the section will show. If the new parameter is not in that list, but is the only parameter is not supplied in that section in a document, the section will not show.
- Add a line for the parameter, follow the example of one of the other lines.
- Create a new template "Chembox Yourparametername", this template formats one complete row in the Chembox (it uses the normal format for a row in a wikitable).
Simple example
Adding parameter |LD50= to the {{Chembox Hazards}} is summarised in the following three edits:
- Add the field to the desired sub-box: diff
- In the first line the field {{{LD50|}}} is added to the selection line. If one of the parameters in this line is supplied, the box appears (including the header), if all are empty, the box does not show at all. If this is omitted, the box does not appear if this is the only parameter that is supplied!
- The second line is the addition of the line itself: {{Chembox entry|par_name={{#if:{{{LD50|}}}|LD50 }} |par_value={{#if:{{{LD50|}}}|{{{LD50}}} }} }}. The placing of the line determines the placing of the field in the box (the order of the fields). The variable 'par_name' determines the sub-box that is called, 'par_value' (and 'par_value1', 'par_value2', etc.) give the parameters to the display template (see 2)
- Add the field to the example list for future reference.
- Create the display template {{Chembox LD50}}. As the chosen fieldname is 'LD50', the name of the display template is 'Chembox LD50'
- Contents:
| [[Median lethal dose|LD<sub>50</sub>]] | {{{value}}} |-<noinclude>[[Category:Chembox templates|{{PAGENAME}}]]</noinclude>
(this is one line of a table, all other parts are determined by the other templates. Should have 2 columns (or otherwise be tweaked to appear as two columns)! First column contains the name as displayed in the left column, the right column contains the formatting for the parameter; parameter is now named '{{{value}}}; further parameters are value1, value2 etc.).
- Contents:
- Add the field to the main template for reference: diff