Inhaltsverzeichnis
WvdS.DokuWiki.Cond Plugin
Plugin: wvdscond
Version: 1.0.0
Namespace: lib/plugins/wvdscond/
Author: Wolfgang van der Stille zeljko.petrusic@outlook.de
License: GPL 2
Migration from wvdsif: This plugin replaces the old
wvdsif plugin and extends it with redirect functionality.
The existing syntax <ifgroup>, <ifnotgroup> and <iflang> remains fully compatible.
Definition
The wvdscond plugin combines conditional content display and server-side redirects in one plugin. It provides:
- Conditional tags -
<ifgroup>,<ifnotgroup>,<iflang> - Redirects -
redirect_targetwith variable support - Negation -
<ifgroup !guest>or<ifnotgroup guest>
Use Cases
- Permission-based content - Different content for guests, users, admins
- Multilingual start pages - Language-specific greetings and content
- Automatic language redirect - Redirect based on browser language
- Login redirects - Redirect after login
- Conditional redirects - Redirects only for specific groups
Syntax
ifgroup - By User Group
<ifgroup groupname>Content for this group</ifgroup> <ifgroup group1,group2>Content for multiple groups</ifgroup> <ifgroup !guest>Content for NON-guests</ifgroup>
ifnotgroup - Negation
<ifnotgroup guest>Content for logged-in users</ifnotgroup> <ifnotgroup admin>Content for non-admins</ifnotgroup>
iflang - By Browser Language
<iflang languagecode>Content for this language</iflang> <iflang code1,code2>Content for multiple languages</iflang> <iflang *>Fallback content (always shown)</iflang>
wvds:redirect - Server-side Redirect
{{wvds:redirect target="de:start"}}
{{wvds:redirect target="{lang}:start"}}
{{wvds:redirect target="int:home" ifgroup="user"}}
{{wvds:redirect target="{lang}:pub:start" ifnotgroup="user"}}
Redirect Variables
| Variable | Replaced by | Example |
|---|---|---|
{lang} | Browser language | de, en, sl |
{group} | First user group | user, admin, vip |
{user} | Username | wvds |
{ns} | Current namespace | de:docs |
Redirect Parameters
| Parameter | Type | Description |
|---|---|---|
target | Required | Target page (Page-ID or with variables) |
ifgroup | Optional | Redirect only for this group(s) |
ifnotgroup | Optional | Redirect only if NOT in group(s) |
Group Parameters
| Parameter | Type | Description |
|---|---|---|
guest | predefined | Non-logged-in visitors |
user | predefined | All logged-in users |
admin | predefined | Administrators |
[groupname] | user-defined | Any group defined in DokuWiki |
Examples
Example 1: Language-based Redirect
Requirement: Start page automatically redirects to browser language.
{{wvds:redirect target="{lang}:start"}}
Result:
- Browser in German: Redirect to
de:start - Browser in English: Redirect to
en:start - Browser in Slovenian: Redirect to
sl:start
Example 2: Login Redirect
Requirement: Guests are redirected to a public page, logged-in users stay.
{{wvds:redirect target="pub:start" ifnotgroup="user"}}
Result:
- Guest: Redirect to
pub:start - Logged in: No redirect
Example 3: VIP Area
Requirement: Non-VIPs are redirected to info page.
{{wvds:redirect target="info:upgrade" ifnotgroup="vip,premium"}}
<ifgroup vip,premium>
===== VIP Area =====
Welcome to the exclusive area!
</ifgroup>
Example 4: Multilingual Start Page
Requirement: Greetings in different languages.
~~NOCACHE~~ <iflang de> ===== Willkommen ===== Dies ist unsere Wissensdatenbank auf Deutsch. </iflang> <iflang en> ===== Welcome ===== This is our knowledge base in English. </iflang> <iflang *> ===== Welcome ===== Please select your language. </iflang>
Example 5: Admin Navigation
Requirement: Admin links only visible for admins.
~~NOCACHE~~ ===== Navigation ===== * [[.:start|Start Page]] * [[.:docs:index|Documentation]] <ifnotgroup guest> * [[.:intern:index|Internal Area]] </ifnotgroup> <ifgroup admin> * [[.:admin:index|Administration]] </ifgroup>
How It Works
Redirect Processing
1. Pattern Recognition
└── Finds {{wvds:redirect ...}}
2. Condition Check (if present)
├── ifgroup: Checks group membership
└── ifnotgroup: Checks NON-membership
3. Variable Replacement
├── {lang} → Browser language
├── {user} → Username
├── {group} → First group
└── {ns} → Current namespace
4. Redirect Execution
├── HTTP 301/302 header (preferred)
├── Meta-Refresh (fallback)
└── JavaScript (fallback)
Security Notes
- Redirects use wl() for internal URLs (Open Redirect Prevention)
- External URLs not allowed (CWE-601 protection)
- All output escaped with hsc() (XSS protection)
Configuration
The plugin requires no special configuration. Group detection uses standard DokuWiki ACL groups.
Important Note
Pages with conditional tags should use
so content is re-rendered on each request.
Migration from wvdsif
| Old (wvdsif) | New (wvdscond) | Status |
|---|---|---|
<ifgroup user> | <ifgroup user> | Compatible |
<iflang de> | <iflang de> | Compatible |
| - | <ifnotgroup guest> | NEW |
| - | redirect | NEW |
Version Notes
| Version | Date | Changes |
|---|---|---|
| 1.0.0 | 2026-01-29 | Initial release |
See Also
- WvdS.DokuWiki.i18n Plugin - Translation plugin (successor to wvdslang)
- WvdS.DokuWiki.Snippet Plugin - Reusable HTML building blocks
- WvdS.DokuWiki.Flat Template - Template with language switcher
Technical Reference
Class: syntax_plugin_wvdscond
File: lib/plugins/wvdscond/syntax.php
| Method | Description |
|---|---|
getType() | Returns substition |
getSort() | Returns 100 |
connectTo($mode) | Registers ifgroup, ifnotgroup, iflang, redirect patterns |
handle($match, …) | Parses tag and extracts condition |
render($mode, …) | Returns content, redirect, or empty |
Class: helper_plugin_wvdscond
File: lib/plugins/wvdscond/helper.php
| Method | Description |
|---|---|
getUserGroups() | Returns all user groups |
checkGroup($groups) | Checks if user is in group |
checkNotGroup($groups) | Checks if user is NOT in group |
detectBrowserLang() | Detects browser language |
checkLang($langs) | Checks language match |
replaceVariables($target) | Replaces {lang}, {user}, etc. |
wvdscond PluginAudit bestanden • 2026-03-30▾
Zuletzt geändert: on 2026/01/29 at 07:51 PM
Diskussion