Template:AssignBeneficial
From Pestinfo-Wiki
The template takes the following 4 parameters from the fields of the subform "Beneficial records" in the "Publication" form:
- assigned beneficial
- assigned pest (may be blank)
- assigned crop (may be blank)
- assigned country (may be blank)
and assigns an internal object to these parameters. In addition, it checks if the beneficial entry (parameter 1) belongs to a higher category (see Template:GetCategory). If yes, it makes additional SemanticMW assignments. A higher category is only found if parameter 1 is not itself already a category. The following two additional assignments are made:
- A normal SemanticMW assignment for the first category found. E.g. if the the beneficial is "Oryctes rhinoceros nudivirus (entomopathogen)" then the literature record is also assigned to "Nudivirus (genus - entomopathogens)".
- An additional internal object assignment to the first higher category found, using the parameters 2 to 4.
The template has the following structure:
1. Internal object assignment with the above 4 parameters. {{#set_internal:Beneficial record|Beneficial={{{1}}}|Pest={{{2}}}|Crop={{{3}}}|Country={{{4}}} }} 2. Define the variable "Category" to take a higher pest category (and later also a higher crop category) {{#vardefine:Category|{{GetCategory|{{{1}}} }} }} 3. If a higher category has been found... {{#if:{{#var:Category}}| 3a. Make an additional normal SematicMW assignment with the category [[Publication on beneficial::{{#var:Category}}| ]] 3b. Make an additional internal object assignment {{#set_internal:Beneficial record|Beneficial={{#var:Category}}|Pest={{{2}}}|Crop={{{3}}}| Country={{{4}}} }} }} (end of "{{#if:{{#var:Category}} ...")