Hdr
This is the template sandbox page for Template:Conditional heading (diff). |
This template should not be substituted. |
This template is designed to create conditional headers for transcludable pages where the heading level may be different on the transcluding and transcluded page. The typical usage is for a project or talk subpage which may benefit from subheadings and a table of contents, but where the transcluding page should generate a section heading at a different level.
Usage
edit{{conditional heading|Example heading|Talk:Example article/Sources}}
⟶ an H2 heading at the subpage, H3 elsewhere{{conditional heading|Example heading|Talk:Example article/Sources|2|4}}
⟶ H2 at the subpage, H4 elsewhere{{chead|header=Example heading|basepage=Talk:Example article/Sources|baselevel=2|otherlevel=4}}
⟶ same as above
Usage note: this template must be placed flush left on a new line by itself, just as for section headings. Placing it mid-line will simply generate plain-text with equal signs, and not be interpreted as a heading ( just as for section headings).
Parameters
editThere are four parameters, one required, and three optional:
|1=
section heading text (required, no default; alias|header=
)|2=
basepage; along with baselevel, defines the section heading level (optional; alias|basepage=
)|3=
is the level number of the heading on the base page: valid values are 0 through 6. (optional; alias:|baselevel=
; default is2
: the equivalent of a== Main heading ==
.|level=1
is equivalent to page title.)|4=
is the level number of the heading on the transcluding page: valid values are 0 through 6. (optional; alias:|otherlevel=
; default is one more than the value of|baselevel=
, or3
if there isn't one.
Parameter notes: the level numbers in optional parameters 3 and 4 are as defined at Help:Wikitext#Layout. Normal values are therefore from 1 to 6 (although '1' is not normally used, so effectively 2 to 6). The special value of 0
means to skip generating the section heading entirely.
If you leave off optional parameters 3 and 4, the template will create a level 2 heading on the basepage, and a level 3 heading on the transcluding page.
It's best not to mix positional parameters with named aliases, use all positional, or all named.
Examples
editIt's in the nature of this template that examples displayed on one page cannot demonstrate the full feature set, because the whole point is that the headings appear differently on transcluding pages. These examples are a starter set, showing how they would appear on a single page.
Markup | Renders as |
---|---|
{{conditional heading|Example heading|Template:Conditional heading/doc|4}} {{chead|Another heading|Talk:Example article/Sources|3}} |
Example headingAnother heading |