2 * ConditionalShowSection MediaWiki extension
4 * @author Jean-Lou Dupont
6 * @subpackage Extensions
7 * @licence GNU General Public Licence 2.0
8 * This extension enables to conditionally show/hide a section
9 * of wikitext that appears between the <cshow> </cshow> tags.
11 * Add to LocalSettings.php
12 * with: require_once("extensions/ConditionalShowSection/ConditionalShowSection.php");
15 * 1.1: corrected bug when "ingroup" option not present, wrong results.
16 * 1.2: used "recursiveTagParse" to get cleaner parsing.
17 * 1.3: corrected error with default initialisation of userReqLogged
18 * 1.4: changed to using 'getEffectiveGroups' in order to have also access
19 * to the implicit '*' group and the default group for logged users 'user'.
20 * 1.5: Allow to check multiple groups - separated by ","
25 {{Extension|templatemode =
26 |name = ConditionalShow
31 |hook1 = ParserFirstCallInit
33 |username = [[user:jldupont]]
35 |description = Conditionally show a wikitext section based on user group rights
40 |mediawiki = tested on 1.8.2, 1.9.3, 1.10, 1.14, 1.15, 1.16A
42 |license = GNU General Public Licence 2.0
43 |download = [http://wiki.jldupont.com/Extension:ConditionalContent http version <1.5]
47 |tags = <cshow>,</cshow>
53 ==What can this extension do?==
54 This extension implementes the <nowiki><cshow></nowiki> tag which conditionally shows wikitext within the tags based on user group rights and certain other parameters.
56 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.
57 <div style="width: 80%; margin-left: auto; margin-right: auto; padding: 4px; border: 2px solid #FF0000; background-color: #FFDDDD; text-align: center;">
60 This tag does not protect information or instructions from being disclosed to the reader.
62 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!
64 This extension only helps you selectively show content or navigation based on groups the user belongs to.
68 This extension is not 'cache' friendly; if one requires this feature, then [[Extension:BizzWiki|BizzWiki platform]] provides a solution through [[Extension:ParserPhase2|Parser Phase 2 extension]].
72 Like other tags, this can be used two ways - by using the tag itself within wikitext, or by using the tag function within templates.
74 If you are using it within normal wikitext, the <nowiki><cshow>. . .</cshow></nowiki> syntax suffices. If you are using it within a template, you will need to use the parser tag function as illustrated [[#Example within a Template | below]].
76 ===Example in Wikitext===
77 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'
80 <cshow logged=1 ingroup='sysop'> This text will appear if a user with membership to 'sysop' group views this page</cshow>
83 ===Example within a Template===
85 If you are using this within a template or as part of a template, you need to use the <nowiki>{{##tag: . . .}}</nowiki> syntax.
89 This text will appear if a user with membership to 'sysop' group views this page
90 | logged=1 ingroup='sysop'
96 By default, the tagged section is HIDDEN unless the following conditions are met:
97 * Argument: logged = '1' or '0'
98 * Argument: ingroup = 'group XYZ' (Note, as of version 1.5, you can list multiple groups, e.g. 'sysop,approved'
100 If no arguments are provided for:
101 logged --> assume 'don't care'
102 innGroup --> assume '' (no group)
104 In other words, if no 'ingroup' parameter is given, then the condition 'ingroup' is never met.
106 If no "logged" parameter is given, then this condition is always met.
108 ==Download instructions==
110 The current version is available from SVN.
112 Source Code and additional information can also be found at [http://bluecortex.com/index.php?title=Bluecortex:ConditionalShow].
113 The code should be loaded to:
115 <code>$IP/extensions/ConditionalShowSection/ConditionalShowSection.php</code>. ''Note: [[Manual:$IP|$IP]] stands for the root directory of your MediaWiki installation, the same directory that holds [[Manual:LocalSettings.php|LocalSettings.php]]''.
118 To install this extension, add the following to [[Manual:LocalSettings.php|LocalSettings.php]]:
120 require_once("$IP/extensions/ConditionalShowSection/ConditionalShowSection.php");
124 * [[Extension:ConditionalContent]]
126 [[Category:View page extensions]]