© 2025 conf:title
</div>
<div class="links">
<a href="?id=imprint">menu_imprint</a>
<a href="?id=privacy">menu_privacy</a>
</div>
</footer>
</code>
Examples
Example 1: Main Menu in Sidebar
Requirement: Central navigation menu for all pages.
Snippet Definition:
[main_menu]
<nav class="main-menu">
<ul>
<li><a href="?id=start">Home</a></li>
<li><a href="?id=en:docs:start">Project Documentation</a></li>
</ul>
</nav>
Usage in sidebar.txt:
~~NOCACHE~~
{{wvds:snippet>main_menu}}
Result:
Menu appears on all pages
Translations are automatically applied
Changes are centralized in configuration
Example 2: Back Link with Icon
Requirement: Uniform back link in sub-namespaces.
Snippet Definition:
[go_back]
<div class="go-back" style="margin-bottom: 1em;">
<i class="fa fa-arrow-left" style="margin-right: 0.5em;"></i>
<a href="javascript:history.back()">de:Zurück|en:Back|sl:Nazaj</a>
</div>
Usage in sidebar1.txt:
~~NOCACHE~~
{{wvds:snippet>go_back}}
{{wvds:acmenu}}
Requirement: Reusable contact information.
Snippet Definition:
[contact_box]
<div class="contact-box">
<h4>de:Kontakt|en:Contact|sl:Kontakt</h4>
<p>
<i class="fa fa-envelope"></i> info@example.com<br>
<i class="fa fa-phone"></i> +49 123 456789
</p>
</div>
Usage:
{{wvds:snippet>contact_box}}
Requirement: Footer with dynamic year and localized links.
Snippet Definition:
[footer]
<footer class="site-footer">
<div class="footer-content">
<p>© 2025 conf:title</p>
<nav class="footer-links">
<a href="?id=imprint">menu_imprint</a> |
<a href="?id=privacy">menu_privacy</a> |
<a href="?id=sitemap">menu_sitemap</a>
</nav>
</div>
</footer>
How It Works
Processing Pipeline
1. Syntax Detection
└── Finds all {{wvds:snippet>...}} tags
2. Snippet Lookup
└── Searches snippet name in configuration
└── Extracts HTML content
3. wvdsi18n Processing
└── Replaces ... tags in snippet
└── Applies current language
4. HTML Output
└── Inserts processed HTML code into page
└── No additional escaping (raw HTML)
Processing Order
| Priority | Plugin | Sort Value |
| 1 | wvdsi18n | 305 |
| 2 | wvdssnippet | 310 |
| 3 | wvdsimage | 319 |
wvdsi18n is processed before wvdssnippet so that translations in snippets work correctly.
Integration
With wvdsi18n
Snippets support all wvdsi18n syntax variants:
[multilingual_block]
<div class="info">
greeting
de:Hallo|en:Hello|sl:Zdravo
{{wvds:lang:en>english_only_text}}
</div>
Typical sidebar structure:
~~NOCACHE~~
{{wvds:snippet>go_back}}
{{wvds:acmenu}}
With wvdsimage
Snippets can also contain images:
[logo_block]
<div class="logo">
{{wvds:image>wiki:logo.png|width=100%|maxwidth=200}}
</div>
Security
Advantages over htmlok
| Aspect | htmlok | wvdssnippet |
| HTML Input | Free in every page | Only via Admin |
| Security Risk | High (XSS, Injection) | Low (controlled) |
| Audit | Difficult (scattered) | Easy (central) |
| User Rights | Anyone with edit rights | Administrators only |
Best Practices
Keep JavaScript minimal - Only when absolutely necessary
External links with target=„_blank“ - Security with rel=„noopener“
No sensitive data - No
API keys, passwords in snippets
Unique names - Choose descriptive snippet names
Error Handling
Behavior on Errors
| Scenario | Behavior |
| Snippet not found | Outputs [snippet_name not found] |
| Empty snippet | Outputs nothing |
| Invalid format | Ignores invalid lines |
| wvdsi18n error | Returns key (fallback) |
Debugging
If problems occur, check:
Is the snippet name spelled correctly?
Does the definition start with [name]?
Is set for dynamic content?
Do the wvdsi18n tags work individually?
Recommendations
| Scenario | Recommendation |
| Static snippets | Leave cache enabled |
| Dynamic snippets (language) | Use |
| Large snippets | Split into smaller ones |
| Many snippets | Don't define more than 50 |
Caching
Pages with language-dependent snippets should have at the beginning so the correct language version is displayed.
Version History
| Version | Date | Changes |
| 2.0.0 | 2026-01-06 | Renamed from wvdschunk to wvdssnippet |
| 1.0.0 | 2025-01-06 | Initial release |
See Also
Technical Reference
Class: syntax_plugin_wvdssnippet
File: lib/plugins/wvdssnippet/syntax.php
| Method | Description |
getType() | Returns substition |
getSort() | Returns 310 (after wvdsi18n) |
connectTo($mode) | Registers pattern \\{\\{wvds:snippet>[^}]+\\}\\} |
handle($match, …) | Extracts snippet name |
render($mode, …) | Outputs HTML content |
Private Methods
| Method | Parameters | Returns | Description |
getSnippet() | $name | string | Searches snippet in configuration |
parseSnippets() | $config | array | Parses snippet definitions |
processSnippet() | $content | string |