Template:Subjects/4
This template is used on many pages and changes may be widely noticed. Test changes in the template's /sandbox or /testcases subpages, or in your own user subpage. Consider discussing changes on the talk page before implementing them. |
This is one of a series of sub-templates of {{subjects}} that add the current page to allbooks categories.
Usage
There are three required parameters and two optional. One of the required parameters may be blank.
ping
— Optional. If non-blank, this template is only being called to make sure it exists.subject
— Required. Names a subject to whose allbooks category this page should be added.origin
— Required. Names the previously visited subject, if any, which provided the value forsubject
; may be blank.n
— Required. An integer that names this template. The first template in the series is called 0, the second is 1, and so on.diagnose
— Optional. If non-blank, diagnostic messages are provided when errors are detected, together with suggestions to fix the problem and buttons to act on the suggestions.
If ping
is non-blank, this template simply returns "ping" without doing anything else. This makes it possible for each template in the series to look for the next template in the series without using expensive parser function {{#ifexist:}} (instead, simply ping the next template and compare the result to "ping").
Otherwise, this template first requests the current page be added to the allbooks category associated with Subject:subject
, via {{Subjects/allbooks}}. Then it checks to see whether the subject page itself exists and is suitably formatted for extraction of its parent parameters. If all is well, it extracts the parent parameters from the subject page, and passes each of them in turn to the next sub-template in the series. Otherwise, it adds the current page to Category:Attention needed (allbooks), and if in addition diagnose
is non-blank, also calls {{subjects/diagnose subject}}.
When calling the next template in the series, the identity of the next template is determined via {{subjects/name next}}, which detects when there are no more templates available in the series and in that case diverts the call to {{subjects/upper bound}}.
See also
- {{subjects/leaf}}