Difference between revisions of "Template:Collapsible option/sandbox"

From blackwiki
Jump to navigation Jump to search
Line 4: Line 4:
 
* {{para|state|collapsed}} to display it in its [[Help:Collapsing|collapsed]] state, i.e. hidden apart from its titlebar;
 
* {{para|state|collapsed}} to display it in its [[Help:Collapsing|collapsed]] state, i.e. hidden apart from its titlebar;
 
* {{para|state|autocollapse}} to show it in its collapsed state ''but only if'' there is another template of the same type on the page. (This is the usual default.)
 
* {{para|state|autocollapse}} to show it in its collapsed state ''but only if'' there is another template of the same type on the page. (This is the usual default.)
For instance, <code><nowiki>{{</nowiki><includeonly>{{BASE</includeonly>PAGENAME<includeonly>}}</includeonly>&#8201;|state=expanded<nowiki>}}</nowiki></code>.
+
For instance, <code><nowiki>{{</nowiki><includeonly>{{BASE</includeonly>PAGENAME<includeonly>}}</includeonly>&#8201;|state=expanded<nowiki>}}</nowiki></code>.<!--
{{#if:{{{align|}}} |<br/>To specify this template's alignment, include the parameter {{para|align|''value''}}, where ''value'' can be <code>right</code>, <code>left</code> or (default) <code>center</code>.}} {{#if:{{{width|}}} |{{#if:{{{align|}}}|<br/>}} To specify this template's width, include the parameter {{para|width|''value''}}, where ''value'' can be a percentage (e.g. {{para|width|80%}}), a length (e.g. {{para|width|22[[Em (typography)#CSS|em]]}}) or <code>auto</code>. The default is {{para|width|100%}}.}}<!--
+
-->{{#if:{{{align|}}} |<br/>To specify this template's alignment, include the parameter {{para|align|''value''}}, where ''value'' can be <code>right</code>, <code>left</code> or (default) <code>center</code>.}}<!--
 +
-->{{#if:{{{width|}}} |<br/>To specify this template's width, include the parameter {{para|width|''value''}}, where ''value'' can be a percentage (e.g. {{para|width|80%}}), a length (e.g. {{para|width|22[[Em (typography)#CSS|em]]}}) or <code>auto</code>. The default is {{para|width|100%}}.}}<!--
 
   Add {{pp-template}} if template page where this template transcluded is protected: -->{{Template other |{{#if:{{PROTECTIONLEVEL:edit}} |{{pp-template|docusage=yes}} |{{#if:{{PROTECTIONLEVEL:move}}|{{pp-move|docusage=yes|small=yes}}}} }} }}<noinclude>{{Documentation}}</noinclude>
 
   Add {{pp-template}} if template page where this template transcluded is protected: -->{{Template other |{{#if:{{PROTECTIONLEVEL:edit}} |{{pp-template|docusage=yes}} |{{#if:{{PROTECTIONLEVEL:move}}|{{pp-move|docusage=yes|small=yes}}}} }} }}<noinclude>{{Documentation}}</noinclude>

Revision as of 09:38, 20 April 2015

How to manage this template's visibility

To transclude this template on a page, use {{PAGENAME}}. To specify the state in which it appears, include one of the following parameters:

  • |state=expanded to display the template in its expanded state, i.e. fully visible;
  • |state=collapsed to display it in its collapsed state, i.e. hidden apart from its titlebar;
  • |state=autocollapse to show it in its collapsed state but only if there is another template of the same type on the page. (This is the usual default.)

For instance, {{PAGENAME |state=expanded}}.

Template documentation[view] [edit] [history] [purge]

{{Collapsible option}} provides a standardised message for transclusion on the pages of collapsible templates whose collapsibility may be managed by the parameter |state=.

It may be used on either the template page itself (wrapped within <noinclude>...</noinclude> tags) or on the template's {{documentation subpage}}.

Indicating optional use of state name

The |state= parameter used to manage collapsible templates need not always be named explicitly, i.e. {{Template name|state}} can be the same as {{Template name|state=state}}, if the template is coded that way. To indicate this in the {{Collapsible option}} message, add the parameter |statename=optional. This modifies the message so that it reads (if it were used for itself):

Initial visibility: currently defaults to autocollapse

To set this template's initial visibility, the |state= parameter may be used:

  • |state=collapsed: {{Collapsible option|state=collapsed}} to show the template collapsed, i.e., hidden apart from its title bar
  • |state=expanded: {{Collapsible option|state=expanded}} to show the template expanded, i.e., fully visible
  • |state=autocollapse: {{Collapsible option|state=autocollapse}}
    • shows the template collapsed to the title bar if there is a {{navbar}}, a {{sidebar}}, or some other table on the page with the collapsible attribute
    • shows the template in its expanded state if there are no other collapsible items on the page

If the |state= parameter in the template on this page is not set, the template's initial visibility is taken from the |default= parameter in the Collapsible option template. For the template on this page, that currently evaluates to autocollapse.

This possibility is enabled by including:

  • {{{1|}}} as part of a collapsible template's |state= parameterTemplate:Spaced ndashfor instance, as |state={{{state|{{{1|}}}}}} or |state={{{state|{{{1|<noinclude>expanded</noinclude>}}}}}}, etc.
  • <noinclude>,<includeonly>as part of a collapsible template's state argumentTemplate:Spaced ndashfor instance, as |state={{{state<includeonly>|collapsed</includeonly>}}}

If, however, the template includes collapsible sections within itself (e.g. {{Navbox with collapsible groups}}), then enabling this possibility may introduce ambiguity as regards what is to be collapsed or expanded. In those instances, therefore, the requirement to use |state= should be retained.

Changing the default state

To change the default state {{Collapsible option}} uses, add the parameter |default=collapsed or |default=expanded accordingly. To restore the default, remove any |default= previously included.

The |default=collapsed option must not be used in main article content in mainspace, e.g. to hide tables of information, or to cram extraneous details into infoboxes. (For more information, see Script error: No such module "Section link"..) This option is permissible in navboxes, which are not part of the article content per se.

Slashes and the nobase parameter

If the template name given to {{Collapsible option}}</nowiki> includes a forward-slash (virgule) character – / – then the parameter |nobase= (set to on, true, etc.) will need to be added so that the name is displayed correctly (i.e., so that {{PAGENAME}} rather than the default {{BASEPAGENAME}} is used to display it).

See also