Plugin sidebar order + directory layout from index.md

- PluginManager: iterate allowedPlugins in user-defined order (frontmatter order)
- content-edit.twig: plugin list with up/down arrows to set order
- Directory listing: read layout/plugins from index.md if present
- Directory default layout: full_content (no sidebar) unless index.md says otherwise
This commit is contained in:
2026-08-11 17:04:27 +02:00
parent 342112cd21
commit 03a14126ca
4 changed files with 143 additions and 33 deletions
+51 -23
View File
@@ -140,28 +140,27 @@ class PluginManager
public function getSidebarContent(?array $allowedPlugins = null): string
{
$sidebarContent = '';
foreach ($this->plugins as $pluginName => $plugin) {
if (!$this->isPluginViewable($plugin) || !method_exists($plugin, 'getSidebarContent')) {
continue;
}
if ($allowedPlugins !== null && !in_array($pluginName, $allowedPlugins, true)) {
continue;
}
$content = $plugin->getSidebarContent();
if (trim($content) === '') {
continue;
}
$title = 'Plugin';
if (method_exists($plugin, 'getConfig')) {
$config = $plugin->getConfig();
$title = $config['title'] ?? 'Plugin';
}
$sidebarContent .= '
// If allowedPlugins is specified, iterate in that order (user-defined order)
if ($allowedPlugins !== null) {
foreach ($allowedPlugins as $pluginName) {
$plugin = $this->plugins[$pluginName] ?? null;
if (!$plugin || !$this->isPluginViewable($plugin) || !method_exists($plugin, 'getSidebarContent')) {
continue;
}
$content = $plugin->getSidebarContent();
if (trim($content) === '') {
continue;
}
$title = 'Plugin';
if (method_exists($plugin, 'getConfig')) {
$config = $plugin->getConfig();
$title = $config['title'] ?? 'Plugin';
}
$sidebarContent .= '
<div class="card mb-3">
<div class="card-header">
<h5 class="mb-0">' . htmlspecialchars($title) . '</h5>
@@ -170,8 +169,37 @@ class PluginManager
' . $content . '
</div>
</div>';
}
} else {
// No filter — show all viewable plugins in load order
foreach ($this->plugins as $pluginName => $plugin) {
if (!$this->isPluginViewable($plugin) || !method_exists($plugin, 'getSidebarContent')) {
continue;
}
$content = $plugin->getSidebarContent();
if (trim($content) === '') {
continue;
}
$title = 'Plugin';
if (method_exists($plugin, 'getConfig')) {
$config = $plugin->getConfig();
$title = $config['title'] ?? 'Plugin';
}
$sidebarContent .= '
<div class="card mb-3">
<div class="card-header">
<h5 class="mb-0">' . htmlspecialchars($title) . '</h5>
</div>
<div class="card-body">
' . $content . '
</div>
</div>';
}
}
return $sidebarContent;
}