User:Zigger/autosection/doc

Autosections allow interactive hiding and showing of entire sections, without breaking the header structure. They can optionally be embedded within another autosection for a cascading effect, without regard to header level. The template can be used anywhere on a line, unlike "==". Autosections are containers for their contents, unlike traditional wiki sections which currently require additional hackery for interaction and stylisation. Both types can be used within the same page.

Autosections currently have three flaws compared to wiki sections: anchors don't work when parents are collapsed, they have no section-editing features, and they are less convenient to create (although easier to customise).

CSS styles can be applied to the entire autosection as one or more of the parameters, and most of these styles settings are inherited automatically by any embedded autosections, with others available through the use of the heir parameter (or explicit setting via other styling parameters).

Simple example:


 * title : The title of the section. The default value is "Missing section title parameter (more...)". This parameter name can be omitted if the title is supplied as the first parameter.  (If the title value starts with an " " character (e.g. " "), this will be treated by mediawiki as increasing the "depth". assuming that there is a matching ending "=" character.)  This parameter can also be named as 1. e.g.
 * depth : Section indentation depth, i.e. HTML heading level less two. The default value is 0.  Values other than -1, 0, 1, 2 or 3 will result in a value of 4.  Outer sections can use the default or specify 0.  The next inner section level must specify 1, and so on.  The resulting HTML header level will be a number two greater than depth.  (A value of -1, resulting in HTML heading level 1, is reserved by mediawiki for the page title, and should be avoided.)  Section embedding is not controlled by depth, but can be easily done by placement of the start and end templates (see the full examples).
 * state : Whether the section is shown initially. The default is that it is shown, which also ensures that printing & other non-interactive renderings of the initial view are complete (strongly recommended for pages in the article namespace, despite the popularity of "spoilers").  Use " " if you want the section to be hidden initially.  Using " " initially collapses the autosection only if there are two or more autosections (or collapsible tables such as navboxes) on the same page.  Other values can produce various results (as state is used in the class list for the "section table").
 * anchorN: In addition to the anchor for the section title, which is always set automatically, this parameter allows additional anchors to be set, e.g.



See also: Template:Anchor.
 * Test autosection anchors on this page: title=Limitations (due to the template design), anchor1=Limitations.


 * width: The minimum percentage width of the section (within the parent container). The default is " ".  A useful value for a messagebox-type size is " ".  Using " " is equivalent to using " ", but width is more convenient.  Use style to set width in other units, e.g. " ", or to use the " " and " " variations.  Please note that the width is more of a guideline than an absolute, with browsers expected to follow various CSS computations.
 * color : The background color, which is a CSS parameter. The default is inherited from the "parent container".  Examples of valid CSS values are " ", " " and " ".  Using " " is equivalent to using " ", but color is more convenient.
 * style : Any extra CSS style setting or combination thereof. Please note that " " sets the default text color of the section, whereas " " is equivalent to " " and sets the background color.  Tip: in CSS, multiple attribute:value tuples are separated by ";", e.g. " ".
 * heir : This allows the autosection to inherit the particular group of style settings which are otherwise reset to standard values by default.  Use " " to instead inherit these particular style settings from the parent container.  Please note that all other style settings are inherited regardless, except for those explicitly overriden via the color and style parameters.

| External links }}

Please note that the autosection must be terminated by using the same template, but without any parameters. Full examples are in the next sections.

This is an example of a single autosection.

This is a parent autosection. This is an embedded auto-section.
 * Chapter 1 |depth=1}}

This is a standard autosection.

This is an independent auto-section with greater "header depth".

See also: [ Pages using this template].


 * TOC / anchor navigation to embedded sub-sections with collapsed parents does nothing at all. Most users would probably expect to end up at the parent at least.  And it's not obvious how to find the top-most collapsed parent in order to expand it.
 * By default, the Table of Contents will appear within the first section's box. It can be moved elsewhere using the   magic word, or can be disabled by using the   magic word.
 * This template is dependent on the site software (MediaWiki), which could be changed at any time by a developer / site operator.
 * Autosections lack section-edit links, and editing the preceding standard section includes the following autosections. (Edit links were shown at Special:ExpandTemplates in early November, but not in actual transclusions.)  (See Help:Section &mdash; edit links within parser functions may lack the correct numbering anyway.  But from some pre-processor discussion, it doesn't seem impossible, as long as a parameter is used.  Could start experimenting with layout, or patch mediawiki.)
 * This template is dependent on the site-level style-sheets and scripts, which could be changed at any time by an administrator edit.
 * Two problems with the expand/collapse mechanism itself have been seen: inconsistent width shrinkage on collapse, with the first "show" action just resulting in width-correction. (Seen with both outer and embedded autosections.  Also seen with other templates, so probably not bug of this one.)  Browsers' CSS width computations often seem to exclude the section number (if enabled in preferences), causing the title to wrap.  This is often seen with " ".
 * Collapsed sections do not print, but I consider this a feature as it allows one to choose which sections print. (Printing includes show links which indicate that the section is collapsed, but it does seem pointless to print hide links on visible sections.)
 * The [show] tag should be emphasised compared to the [hide] tag.
 * The result is only functional for browsers with javascript enabled. Otherwise the sections are always expanded.


 * Tables are deprecated for layout, although they're still often the path of least resistance. Experiment with divs (see NavFrame for starters).
 * "Rename" this page to something shorter.
 * Test with other resolutions, other fonts and font sizes, other browsers (& js settings), other skins (& other profile settings), rtl (currently using en/ltr UI, IE 7.x, Safari 3.1.x, Firefox 3.0.x, IE 7, Iceweasel/Firefox 2.0.x, Konqueror/KDE 3.5.5).
 * Specifying "depth=1" is too cumbersome &mdash; I'd like this to be an optionally nameless parameter (before or after the title?).
 * Follow-up work may be needed for line-feed / placement issues.
 * Follow-up work is expected to be needed for margin tweaks, including browser differences.
 * Strip few remaining redundant output characters.
 * Share&hellip;


 * Help:Collapsing
 * NavFrame
 * Template:Navbox
 * Help:Section