Plugin: wvdsif
Version: 1.0.0
Namespace: lib/plugins/wvdsif/
Author: Wolfgang van der Stille zeljko.petrusic@outlook.de
License: GPL 2
The wvdsif plugin enables conditional content display based on user groups or browser language. It provides two tag types: <ifgroup> for group-based display and <iflang> for language-based display.
<ifgroup groupname>Content for this group</ifgroup> <ifgroup group1,group2>Content for multiple groups</ifgroup>
<iflang languagecode>Content for this language</iflang> <iflang code1,code2>Content for multiple languages</iflang> <iflang *>Fallback content (always displayed)</iflang>
| Parameter | Type | Description |
|---|---|---|
guest | predefined | Not logged-in visitors |
user | predefined | All logged-in users |
admin | predefined | Administrators |
[groupname] | custom | Any group defined in DokuWiki |
| Parameter | Type | Description |
|---|---|---|
de | ISO 639-1 | German |
en | ISO 639-1 | English |
sl | ISO 639-1 | Slovenian |
fr | ISO 639-1 | French |
es | ISO 639-1 | Spanish |
it | ISO 639-1 | Italian |
* | Wildcard | All languages (fallback) |
Requirement: Different greeting for guests and logged-in users.
<ifgroup guest> ===== Welcome! ===== Please [[?do=login|log in]] for full access. </ifgroup> <ifgroup user> ===== Welcome Back! ===== You have access to all documentation. </ifgroup>
Result:
Requirement: Admin links visible only to administrators.
<ifgroup admin> ===== Administration ===== * [[admin:dashboard|Dashboard]] * [[admin:users|Manage Users]] * [[admin:plugins|Manage Plugins]] * [[admin:config|Configuration]] </ifgroup>
Result:
Requirement: Greeting in the visitor's browser language.
<iflang de> ===== Willkommen ===== Dies ist unsere Wissensdatenbank auf Deutsch. </iflang> <iflang en> ===== Welcome ===== This is our knowledge base in English. </iflang> <iflang sl> ===== Dobrodošli ===== To je naša baza znanja v slovenščini. </iflang> <iflang *> ===== Welcome ===== Please select your language above. </iflang>
Result:
Requirement: 404 page in the visitor's language.
<iflang de> ===== Seite nicht gefunden ===== Die angeforderte Seite existiert nicht. [[start|Zurück zur Startseite]] </iflang> <iflang en> ===== Page Not Found ===== The requested page does not exist. [[start|Back to homepage]] </iflang> <iflang *> ===== Error 404 ===== Page not found. [[start|Home]] </iflang>
Requirement: Premium content only for VIP members.
<ifgroup vip,premium> ===== Exclusive Area ===== Here you'll find premium documentation and advanced tutorials. * [[premium:advanced|Advanced Features]] * [[premium:tutorials|Exclusive Tutorials]] </ifgroup> <ifgroup guest,user> ===== Premium Area ===== This area is reserved for VIP members. [[contact|Request Upgrade]] </ifgroup>
Requirement: Multiple groups in a sidebar.
~~NOCACHE~~ ===== Navigation ===== * [[start|Home]] * [[docs:index|Documentation]] <ifgroup user,admin> * [[internal:index|Internal Area]] </ifgroup> <ifgroup admin> * [[admin:index|Administration]] </ifgroup> <ifgroup guest> * [[?do=login|Log In]] </ifgroup>
1. Tag Detection └── Finds all <ifgroup>...</ifgroup> and <iflang>...</iflang> tags 2. Condition Check ├── ifgroup: Checks $_SERVER['REMOTE_USER'] and group membership └── iflang: Checks Accept-Language header 3. Content Filtering ├── Condition met: Content is displayed └── Condition not met: Content is removed 4. Wildcard Processing └── <iflang *> is checked last (only if no other language matches)
The language is detected from the Accept-Language HTTP header:
Accept-Language: de-DE,de;q=0.9,en;q=0.8
^^
Primary language: "de"
| Header Example | Detected Language |
|---|---|
de-DE,de;q=0.9 | de |
en-US,en;q=0.9 | en |
sl-SI,sl;q=0.9 | sl |
fr-FR,en;q=0.5 | fr |
The plugin requires no special configuration. Group detection uses standard DokuWiki ACL groups.
<ifgroup> or <iflang> tags should use so content is re-rendered on each request.
| Scenario | Behavior |
|---|---|
| Unknown group | Block is not displayed |
| Invalid language code | Block is not displayed |
| No Accept-Language header | Only * wildcard is displayed |
| Nested tags | Outer tag takes priority |
<ifgroup admin>Admin content</ifgroup> <ifgroup user>User content</ifgroup>
<ifgroup admin> <ifgroup user>Nested content</ifgroup> </ifgroup>
| Version | Date | Changes |
|---|---|---|
| 1.0.0 | 2025-01-06 | Initial release |
File: lib/plugins/wvdsif/syntax.php
| Method | Description |
|---|---|
getType() | Returns substition |
getSort() | Returns 100 |
connectTo($mode) | Registers ifgroup and iflang patterns |
handle($match, …) | Parses tag and extracts condition |
render($mode, …) | Returns content or empty |
| Function | Description |
|---|---|
_checkGroup($groups) | Checks group membership |
_checkLang($langs) | Checks language match |
_getBrowserLang() | Extracts language from Accept-Language |
| Variable | Source | Description |
|---|---|---|
$_SERVER['REMOTE_USER'] | PHP | Logged-in username |
$USERINFO['grps'] | DokuWiki | User groups array |
$_SERVER['HTTP_ACCEPT_LANGUAGE'] | HTTP | Browser language setting |