Extension:ConditionalShow

From MediaWiki.org
Jump to: navigation, search
MediaWiki extensions manual - list
Crystal Clear action run.png
ConditionalShow

Release status: unmaintained

Implementation Tag, User rights, MyWiki
Description Conditionally show a wikitext section based on user group rights
Author(s) Jean-Lou Dupont (jlduponttalk)
Latest version 1.5 (2009-09-10)
MediaWiki tested on 1.8.2, 1.9.3, 1.10, 1.14, 1.15, 1.16A
License GNU General Public License 2.0
Download
Example examples
Tags
<cshow>,</cshow>
Hooks used
ParserFirstCallInit

Translate the ConditionalShow extension if possible

Check usage and version matrix; code metrics

What can this extension do?[edit | edit source]

This extension implements the <cshow> tag which conditionally shows wikitext within the tags based on user group rights and certain other parameters.

Using the tags should be to make the user experience less confusing or more useful by only showing information relevant to the user and specific groups that user belongs to.

PLEASE NOTE!!!

This tag does not protect information or instructions from being disclosed to the reader.

The user can still see the information by editing the page or even by "view source". If you are looking to actually protect information, this is NOT the extension you want to use!

This extension only helps you selectively show content or navigation based on groups the user belongs to.

Note[edit | edit source]

This extension is not 'cache' friendly; if one requires this feature, then BizzWiki platform provides a solution through Parser Phase 2 extension.

Usage[edit | edit source]

Like other tags, this can be used two ways - by using the tag itself within wikitext, or by using the tag function within templates.

If you are using it within normal wikitext, the <cshow>. . .</cshow> syntax suffices. If you are using it within a template, you will need to use the parser tag function as illustrated below.

Example in Wikitext[edit | edit source]

By default, the section of wikitext within the tags is HIDDEN unless the conditions are met - in this case the user must be logged in and belong the group 'sysops'

<cshow logged=1 ingroup='sysop'> This text will appear if a user with membership to 'sysop' group views this page</cshow>

Example within a Template[edit | edit source]

If you are using this within a template or as part of a template, you need to use the {{#tag: . . .}} syntax.

{{#tag:cshow |
This text will appear if a user with membership to 'sysop' group views this page
| logged=1 ingroup='sysop'
}}

For documentation on how to use the #tag parserfunction, Miscellaneous Magic Words

Arguments[edit | edit source]

By default, the tagged section is HIDDEN unless the following conditions are met:

  • Argument: logged = '1' or '0'
  • Argument: ingroup = 'group XYZ' (Note, as of version 1.5, you can list multiple groups, e.g. 'sysop,approved'

If no arguments are provided for: logged --> assume 'don't care' innGroup --> assume (no group)

In other words, if no 'ingroup' parameter is given, then the condition 'ingroup' is never met.

If no "logged" parameter is given, then this condition is always met.

Download instructions[edit | edit source]

The current version is available from SVN.

Source Code and additional information can also be found at [1]. The code should be loaded to:

$IP/extensions/ConditionalShowSection/ConditionalShowSection.php. Note: $IP stands for the root directory of your MediaWiki installation, the same directory that holds LocalSettings.php.

Installation[edit | edit source]

To install this extension, add the following to LocalSettings.php:

require_once("$IP/extensions/ConditionalShowSection/ConditionalShowSection.php");

Announcements[edit | edit source]

  • The text in the conditionalshowsection-desc contained <cshow> which is causes Special:Version to choke. Updated messages so it no longer contains that tag (which should not have been interpreted). This will cause a problem in Special:Version for all versions before MW 1.16.0, so if you are seeing it, download the current message files to correct.

Other Options[edit | edit source]