Writing Plugins for CSE_CMS v2
Plugins let you embed interactive PHP tools (calculators, directories, mini-apps) directly inside the CMS layout without modifying core files.
Plugin Structure
Create a folder inside plugin/ with an alphanumeric/underscore name (e.g. plugin/My_Tool/) containing index.php:
<?php
declare(strict_types=1);
function My_Tool_title(string $lan): string
{
return match ($lan) {
'fr' => 'Mon Outil',
'de' => 'Mein Werkzeug',
default => 'My Tool',
};
}
function My_Tool_content(string $lan): string
{
$action = cse_plugin_url('My_Tool', $lan);
$html = '<p>Hello from My Tool!</p>';
$html .= '<form method="get" action="' . cse_h($action) . '">';
$html .= '<input type="hidden" name="name" value="My_Tool">';
$html .= '<button type="submit" class="cse-btn cse-btn--primary">Run</button>';
$html .= '</form>';
return $html;
}
Exposing a Plugin in the Menu
Place a .plug file inside any language/category folder (for example en/Programming/My_Tool.plug):
name=My_Tool&
text=A short description displayed on the folder overview card.
The CMS automatically routes clicks to /<lan>/CSE_plugin?name=My_Tool and renders your plugin inside the active template and theme.
Best Practices for v2 Plugins
- Use built-in helpers:
cse_h($str)for safe HTML escaping,cse_base_url()for the site root, andcse_plugin_url('My_Tool', $lan)for form/link targets (avoids hardcodedhttp://domains). - Theme-friendly styling: Avoid hardcoded
#fffor#000colors — use the CMS CSS variables (var(--surface),var(--surface-alt),var(--text),var(--border),var(--accent)) so your plugin looks great in Light, Dark, Glass Aurora, and CSE 2008 themes alike. - Private plugin data: Store any plugin data files inside
plugin/My_Tool/data/—.htaccessautomatically blocks direct web access toplugin/*/data/with403 Forbidden.