Template:GetBeneficialCatN
The template takes the pagename of a natural enemy (beneficial) of a pest, e.g. "Orius insidiosus (predator)" and tests if the name is assigned one of the following 11 higher categories:
- Bacteria (entomopathogens)
- Fungi/fungal-like organisms (entomopathogens)
- Pathogenic nematodes (beneficials)
- Viruses (entomopathogens)
- Diseases of pests [other groups]
- Parasitoids - Diptera
- Parasitoids - Hymenoptera
- Parasitoids and parasites - other groups
- Predators - insects
- Predators - mites
- Predators - other groups
If yes, it adds the above number of the category found to the pagename, e.g. for "Orius insidiosus (predator)" it returns "9,Orius insidiosus (predator)". If no category is found it adds the number "99" to the pagename.
The template uses the query
{{#ask:[[Category:<higher category>]][[<beneficial pagename>]]|format=count}}
to test an assignment. It can cause unexpected results if the beneficial is assigned to several categories. E.g. assigning the beneficial "Heterorhabditis bacteriophora/Photorhabdus (entomopathogen)" to the "Category:Heterorhabditis (genus - entomopathogens)" (under "Category:Pathogenic nematodes (beneficials)") as well as to "Category:Photorhabdus (genus - entomopathogens)" (under "Category:Bacteria (entomopathogens)") results then in this template returning the "Category:Bacteria (entomopathogens)". Strangely, this will then also happen for the higher categories. E.g. the nematode family "Heterorhabditidae (beneficial pathogens)" will also return the "Category:Bacteria (entomopathogens)". To avoid such problems beneficials and pests/diseases/weeds should not be assigned to several categories unless they have the same higher groups.
The equivalent templates for antagonists and natural enemies of weeds are Template:GetBeneficialCatA and Template:GetBeneficialCatW.
Note 1:
The template is part of the Template:BeneficialListP where the query
{{#ask:[[Beneficial record::+]][[Pest::{{#var:Speciesname}}]]|mainlabel=-|? Beneficial=| ......}}
can return a category, even if the database assignment does not contain the word "Category:". E.g. if the assignment is "Geocoris (genus - predators)" the query will return "Category:Geocoris (genus - predators)". This behaviour can cause problems in the subsequent processing and interfers with sorting the list. Therefore, this template cuts off any references to "Category:" from the return value.
Note 2:
The structure of this template uses repeated "ifexpr" functions instead of a "while" loop. A loop version of this template is shown in Template:GetBeneficialCatTest. Although that version is easier to understand and to modify it causes format problems. That is: the returned result causes the "arraysort" function in the Template:BeneficialListP to fail.