Recently a cascading style sheets (CSS) "hack" known more generally as "hiddenStructure" has seen widespread use on Wikipedia. This hack makes it possible to conditionally hide rows of data in tables dependent upon whether or not certain parameters are passed (or are/aren't empty/blank).
Problems
The problem with using hiddenStructure is that it hides rows in a non-standard way. Whereas other websites hide data by simply not sending it out from the server[1], hiddenStructure defers this hiding process to the client. Because of this, some non-CSS aware or compliant browsers incorrectly render pages using this hack (see pictures at right).
Some pages minimize the damage by only displaying the variable if it's actually non-blank (using the syntax {{{variable|}}}
). In this way only the row is displayed, not the ugly {{{variable}}} variable name. Of course in templates with large numbers of conditional rows, this still results in unnecessary data being displayed to non-CSS compliant browsers.
Because of these problems many articles render poorly for the disabled. In the worst case, a number of Wiki-markup variables are displayed/read to the reader. In the best case, a number of rows are displayed/read which are empty. For these reasons, hiddenStructure should not be used.
Solutions
Solutions, in order of preference, are.
- Use Weeble code (such as {{row}}).
- Advantage: When conditional syntax is brought into MediaWiki, using Special:Whatlinkshere should make it easy to identify templates which need to be upgraded.
- Use meta-templates such as {{qif}} to conditionally display data.
- Advantage: When conditional syntax is brought into MediaWiki, using Special:Whatlinkshere should make it easy to identify templates which need to be upgraded.
- Limit or eliminate conditional rows.
Other possible solutions, which are ill-advised, include:
- Breaking apart a single template into various multiple other templates, with each handling different combinations of parameters.
- Problem: This is a maintenance nightmare, and goes against the purpose of templates (centralizing maintenance to one place).
Notes
- ^ Most websites use PHP or ASP to conditionally send data from the server. More advanced designs cache results so PHP/ASP scripts are only executed once for each possible outcome.
Diffs
- [1] — Here Brion VIBBER, lead developer of MediaWiki, describes some of the problems with hiddenStructure.
See also
- Wikipedia:HiddenStructure
- Wikipedia:Avoid using meta-templates (deprecated/rejected)