Template:Chembox/doc/Adding a parameter to Chembox

From blackwiki
Jump to navigation Jump to search

Parameter display

Except for the more complicated parameters, the display of most parameters is controlled by their own template. This template creates the actual row (if it is displayed is controlled by the section template).

Example:

  • The parameter "CASNo" -> {{Chembox CASNo}}
  • The parameter "MolarMass" -> {{Chembox MolarMass}}
  • The combination of the parameters ATCCode/ATCvet/ATCCode_prefix/ATCCode_suffix/ATCCode_supplemental are controlled by {{Chembox ATCCode}}

To add a new parameter to the Chembox

  1. Select the section the parameter has to go into, and choose a unique parameter name in that section.
  2. Open the section template for editing.
  3. 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.
  4. Add a line for the parameter, follow the example of one of the other lines.
  5. 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:

  1. Add the field to the desired sub-box: diff
    1. 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!
    2. 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)
    3. Add the field to the example list for future reference.
  2. Create the display template {{Chembox LD50}}. As the chosen fieldname is 'LD50', the name of the display template is 'Chembox LD50'
    1. 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.).
  3. Add the field to the main template for reference: diff