Template:Subjects/0/doc

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. If  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").
 * &mdash; Optional. If non-blank, this template is only being called to make sure it exists.
 * &mdash; Required. Names a subject to whose allbooks category this page should be added.
 * &mdash; Required. Names the previously visited subject, if any, which provided the value for  ; may be blank.
 * &mdash; Required. An integer that names this template.  The first template in the series is called 0, the second is 1, and so on.
 * &mdash; 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.

Otherwise, this template first requests the current page be added to the allbooks category associated with 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  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.