User:Beetstra/Chembox new

This template contains a consistent layout for a box with details about a chemical compound.

Use
Copy the template from one of the forms below into the top of the document, and add data to the fields. Don't worry about trying to fill in all the fields -- even if you can only get the basics, that can still be very useful.

General:
 * Do not delete fields that you don't know the data for, empty fields will just not give a row in the result, and sections without data will also not show up. Other editors may just fill in the fields that are empty.  You can delete sections which are not applicable for the compound (see extra sections/fields).


 * Do not subst this template, empty fields will not show up, and when formatting changes are applied to the template, it will not be visible in all documents transcluding the chembox new. The substituted template is an unintelligble gibberish of esoteric template code, and certain parts will not transclude.  Keeping it un-subst-ed makes placing the data even more easy, and saves a lot of space on a page (the unsubsted chembox new is on an avarage page about 1000 bytes smaller than a fully transcluded chembox).


 * For the sub-box supplement to show up, the supplementary page "pagename (data page)" has to be available. When the chembox grows too big, consider starting a datapage and move data from the chembox into that page.

Getting a chembox new
The chemboxes have a more or less modular design. They are built up out of several sections, and depending on the compound, certain sections can be removed, or other sections can be added.

If the box needs expansion from another field, simply copy the section from the full template form, and paste it into the chembox (make sure that each section has its own number, note that a section starts with "| section# = " ; make sure the sections don't 'nest'). There are 15 sections available (though only 8 have been defined so far).

The order of section numbers does effect the actual order in the final document. If a chemical compound would e.g. both be an explosive and a drug, but the drug properties are more important, consider giving the drug-section a lower sectionnumber than the explosive-section, and the drug-section will appear above the explosive-section. The actual numbering of the sections does not matter (as long as the numbers are in the range 1–15) as long as no duplicate sections are defined.

Available subst templates (type in the document and press save to get the empty box):
 * chembox subst or chembox subst small for standard chemicals
 * chembox subst medium, a bit more information
 * chembox subst full or chembox subst large, a complete list

Specialised:
 * chembox subst drug, a medium box with the pharma box
 * chembox subst explosive, a medium box with the explosive box

Small/simple form
To use, simply copy and paste the left column into the document, filling in whatever you can, or type and press save:

Full form
To use, simply copy and paste the left column into the document, or type and press save to get an empty chembox:

Medium form
To use, simply copy and paste the left column into the document, filling in whatever you can, or type and press save:

Advanced fields in main template
There are some extra fields available:

"Table creep"
The chembox new can handle a lot of parameters, and new ones can easily be added (even more than are shown in the full format). This may result in huge tables in the end. When the table becomes too big, please consider creating a data page 'pagename (data page)', and moving data into that page. Chembox new will automagically recognise the existence of the data page, a new box will show, which will have some links into the data page.

Field order
The order of the parameters in this template does not have any effect on the final layout of the template, that order is either programmed in this template (for the top section) or in the following subtemplates:
 * Chembox Identifiers
 * Chembox Properties
 * Chembox Structure
 * Chembox Thermochemistry
 * Chembox Pharmacology
 * Chembox Explosive
 * Chembox Hazards
 * Chembox Related

And the hidden template:
 * Chembox Supplement (only visible when 'pagename (data page)' exists)

The order of the sections can be changed by changing the numbering of the headings 'Section# = {{chembox section'. This has to be done with some care. Sections that are really without use can be safely removed, renumbering is not necessary.

Extra sections/fields
The setup of the chembox new is modular, one can easily incorporate other boxes in the chembox, by adding a section. The following sections are available (see these templates for more explanation):


 * Chembox Identifiers
 * Chembox Properties
 * Chembox Structure
 * Chembox Thermochemistry
 * Chembox Pharmacology
 * Chembox Explosive
 * Chembox Hazards
 * Chembox Related

Besides the fields that have been defined in the two forms above, there are many other fields available. In this template those are extra image fields (described below), in the separate sections there are also more fields available. For a full list of available fields see the different section templates.

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 parameters ATCCode/ATCCode_prefix/ATCCode_suffix/ATCCode_supplemental are controlled by Chembox ATCCode

Auto images
If there is an image available with the name of the page, that will automagically be used in the template when no other image name is supplied. The order of preference is:


 * 1) If an imagename is supplied in any of the 8 imagefields in the chembox new, then the automatic image will NOT be used.
 * 2) otherwise, 'pagename.svg' will be used if available
 * 3) otherwise, 'pagename.png' will be used if available
 * 4) otherwise, 'pagename.gif' will be used if available
 * 5) otherwise, 'pagename.jpg' will be used if available
 * 6) otherwise, if there is no image available, the document will be autocategorised in Category:Chemical pages needing a structure drawing (handled by chemistry, image request)

The size of the automagic images is defaulted to 200px, but can be set with the parameter ImageSize.

Troubleshooting

 * When supplying a parameter with a value, and nothing or the wrong value shows up, check:
 * Is the parameter placed in the correct section?
 * Is the parameter supplied twice? It will use the value of the second instance
 * Are the sections properly defined. Sections start with | section# = ".
 * Is there inconsistency in the sectionnumbering? Available numbers for sections are 1 - 15, do not use a sectionnumber twice, that will only result in the second section showing up.
 * Is the capitalisation of the parameter correct? "Formula" works, "FORMULA" does not.

Adding a parameter
To add a new parameter to the chembox:
 * 1) Select the section the parameter has to go into, and select a unique parameter name in that section.
 * 2) Edit the section.
 * 3) In the very first if-statement, add "  " 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 new (it uses the normal format for a row in a wikitable).

Simple example
Adding 'LD50' to the chembox Hazards is summarised in the following three edits:


 * 1) Add the field to the desired sub-box: diff
 * 2) In the first line the field 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!
 * 3) The second line is the addition of the line itself: .  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)
 * 4) Add the field to the example list for future reference.
 * 5) Create the display template Chembox LD50.  As the chosen fieldname is 'LD50', the name of the display template is 'Chembox LD50'
 * 6) Contents:


 * LD50

(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 '  ; further parameters are value1, value2 etc.).
 * 1) Add the field to the main template for reference: diff