- Reorganize admin into admin/theme/default/ (views + assets) - Rename GuideNav to Navigation plugin (essential, protected) - Plugin assets support (SCSS/CSS) loaded after theme CSS - User roles: Admin, Content Manager, BI Manager, Site Admin - Role-based access control (RBAC) for admin routes and sidebar - Guide restructure: sub-topics in separate folders with sidebar nav - Dynamic breadcrumb for homepage and subdirectories - Fix theme path traversal (../../ -> ../) in admin.php - Fix CodeMirror mode load order (xml -> css -> js -> htmlmixed -> php) - Fix editor-toolbar.js null checks for plugin edit pages - Layout select from theme.json with live frontmatter update - Footer sticky at bottom of viewport (min-height: 100vh) - Breadcrumb color fix (var(--nav-font) -> var(--header-bg)) - Remove language switcher from guide pages - Update README.md and README.en.md - Bump version to 2.5.1
3.8 KiB
3.8 KiB
Content API
De Content API is beschikbaar in PHP content bestanden (.php) en biedt een veilige, read-only interface tot CMS data.
Gebruik in PHP content bestanden
<?php
/** @var ContentAPI $api */
// Alle pagina's ophalen
$allPages = $api->getAllPages();
// Resultaat: ['index' => 'Home', 'over-ons' => 'Over ons', ...]
// Specifieke pagina ophalen
$page = $api->getPage('over-ons');
// Resultaat: ['title' => 'Over ons', 'content' => '...', 'path' => 'over-ons', 'layout' => 'full_content', 'metadata' => [...]]
// Menu structuur ophalen
$menu = $api->getMenu();
// Resultaat: [['title' => 'Home', 'path' => 'index', 'type' => 'file', 'active' => true], ...]
// Config waarde ophalen (dot notatie)
$siteTitle = $api->getConfig('site_title');
$searchEnabled = $api->getConfig('features.search_enabled', false);
Beschikbare methods
Pagina's
getAllPages(): array- Alle pagina's als['pad' => 'titel']pairsgetPage(string $path): ?array- Specifieke pagina mettitle,content,path,layout,metadatapageExists(string $path): bool- Controleer of een pagina bestaatgetCurrentPageTitle(): string- Titel van huidige paginagetCurrentPagePath(): string- Pad van huidige paginaisHomepage(): bool- Of huidige pagina de homepage is
Menu & Navigatie
getMenu(): array- Hiërarchische menu structuur mettitle,path,children,activebuildUrl(string $page = 'index', ?string $lang = null, array $params = []): string- Bouw een URL voor een pagina
Configuratie
getConfig(string $key, mixed $default = null): mixed- Config waarde via dot notatie (bijv.'features.search_enabled')getSiteTitle(): string- Site titel uit config
Taal
getCurrentLanguage(): string- Huidige taal code (bijv.'nl')getAvailableLanguages(): array- Beschikbare talen (bijv.['nl', 'en'])t(string $key): string- Vertaal een language key
Zoeken
getSearchResults(): array- Zoekresultaten (leeg als niet aan het zoeken)isSearching(): bool- Of er momenteel gezocht wordt
Voorbeeld: Recentste pagina's tonen
<?php
/** @var ContentAPI $api */
$pages = $api->getAllPages();
$currentLang = $api->getCurrentLanguage();
?>
<ul>
<?php foreach (array_slice($pages, 0, 5, true) as $path => $title): ?>
<li>
<a href="/<?= $currentLang ?>/<?= htmlspecialchars($path) ?>">
<?= htmlspecialchars($title) ?>
</a>
</li>
<?php endforeach; ?>
</ul>
Voorbeeld: Config waarde gebruiken
<?php
/** @var ContentAPI $api */
if ($api->getConfig('features.search_enabled', false)): ?>
<form method="GET" action="">
<input type="search" name="search" placeholder="<?= $api->t('search_placeholder') ?>">
<button type="submit"><?= $api->t('search_button') ?></button>
</form>
<?php endif; ?>
CMSAPI (voor plugins)
Plugins gebruiken de CMSAPI class via $this->api. Deze biedt vergelijkbare methods:
$this->api->getCurrentPageTitle();
$this->api->getCurrentPageContent();
$this->api->getMenu();
$this->api->getConfig('site_title');
$this->api->getCurrentLanguage();
$this->api->isHomepage();
$this->api->hasContent();
$this->api->getSearchResults();
$this->api->isSearching();
$this->api->getAvailableLanguages();
$this->api->createUrl('over-ons');
$this->api->translate('home');
Daarnaast heeft de CMSAPI:
getCurrentPage(): array- Volledige pagina datagetCurrentPageUrl(): string- URL van huidige paginagetCurrentPageFileInfo(): ?array- Bestandsinfo (created, modified)getBreadcrumb(): string- Breadcrumb HTMLexecutePhpFile(string $filePath): string- Voer PHP bestand uit en vang output opgetFileContent(string $filePath): string- Haal content uit PHP/HTML/Markdown bestandcontentFileExists(string $filename): bool- Controleer of bestand bestaat in content map