# Content API The Content API is available in PHP content files (`.php`) and provides a safe, read-only interface to CMS data. ## Usage in PHP content files ```php getAllPages(); // Result: ['index' => 'Home', 'about-us' => 'About Us', ...] // Get a specific page $page = $api->getPage('about-us'); // Result: ['title' => 'About Us', 'content' => '...', 'path' => 'about-us', 'layout' => 'full_content', 'metadata' => [...]] // Get menu structure $menu = $api->getMenu(); // Result: [['title' => 'Home', 'path' => 'index', 'type' => 'file', 'active' => true], ...] // Get config value (dot notation) $siteTitle = $api->getConfig('site_title'); $searchEnabled = $api->getConfig('features.search_enabled', false); ``` ## Available methods ### Pages - `getAllPages(): array` - All pages as `['path' => 'title']` pairs - `getPage(string $path): ?array` - Specific page with `title`, `content`, `path`, `layout`, `metadata` - `pageExists(string $path): bool` - Check if a page exists - `getCurrentPageTitle(): string` - Title of current page - `getCurrentPagePath(): string` - Path of current page - `isHomepage(): bool` - Whether current page is the homepage ### Menu & Navigation - `getMenu(): array` - Hierarchical menu structure with `title`, `path`, `children`, `active` - `buildUrl(string $page = 'index', ?string $lang = null, array $params = []): string` - Build a URL for a page ### Configuration - `getConfig(string $key, mixed $default = null): mixed` - Config value via dot notation (e.g. `'features.search_enabled'`) - `getSiteTitle(): string` - Site title from config ### Language - `getCurrentLanguage(): string` - Current language code (e.g. `'nl'`) - `getAvailableLanguages(): array` - Available languages (e.g. `['nl', 'en']`) - `t(string $key): string` - Translate a language key ### Search - `getSearchResults(): array` - Search results (empty if not searching) - `isSearching(): bool` - Whether a search is currently active ## Example: Show recent pages ```php getAllPages(); $currentLang = $api->getCurrentLanguage(); ?>