ContentAPI voor PHP content bestanden + handleiding in admin
- Nieuwe ContentAPI class beschikbaar als $api in PHP content bestanden met methodes: getAllPages, getPage, getMenu, getConfig, buildUrl, etc. - Admin handleiding pagina op /admin/guide met taalwisselaar - Zijbalk link naar handleiding in admin menu - Dubbele alert in config pagina verwijderd - Handleidingen (nl/en) uitgebreid met Content API referentie
This commit is contained in:
+99
-1
@@ -18,7 +18,7 @@ CodePress CMS is a lightweight, file-based content management system built with
|
||||
|
||||
### Content Types
|
||||
- **Markdown (.md)** - CommonMark support via `league/commonmark`
|
||||
- **PHP (.php)** - Dynamic content
|
||||
- **PHP (.php)** - Dynamic content with **Content API** (`$api` variable)
|
||||
- **HTML (.html)** - Static HTML pages
|
||||
- **Directory listings** - Automatic directory overviews
|
||||
- **Language-specific content** - `en.` and `nl.` prefixes
|
||||
@@ -63,6 +63,7 @@ CodePress CMS is a lightweight, file-based content management system built with
|
||||
- **Plugin management** - Overview, create, edit, configure, enable/disable and delete
|
||||
- **Media management** - Upload and delete media files in `content/-assets/`
|
||||
- **User management** - Add, remove users, change passwords
|
||||
- **Guide** - Built-in documentation with API reference
|
||||
- Session-based authentication with bcrypt hashing
|
||||
- CSRF protection, brute-force lockout (5 attempts, 15 min)
|
||||
- Default login: `admin` / `admin` (change immediately after installation)
|
||||
@@ -286,6 +287,7 @@ Media files (images, PDFs, video, audio) can be placed in any `content/` subdire
|
||||
| `media` | Media management (upload, delete) |
|
||||
| `media-list` | JSON list of all media (for editor modal) |
|
||||
| `users` | User management |
|
||||
| `guide` | Guide / documentation |
|
||||
|
||||
### Editor Features
|
||||
|
||||
@@ -491,6 +493,102 @@ class MyPlugin
|
||||
|
||||
The MQTTTracker plugin stores `broker_host`, `broker_port`, `client_id`, `username` and `password` in plain text in `plugins/MQTTTracker/config.json`. This is a known open security issue - in a production environment it is recommended to externalize these credentials to environment variables or a separate credential manager.
|
||||
|
||||
## Content API (for PHP content files)
|
||||
|
||||
PHP content files (`.php` in the `content/` directory) have access to an `$api` variable with the following methods:
|
||||
|
||||
### Getting pages
|
||||
|
||||
```php
|
||||
// Get all pages with titles
|
||||
$pages = $api->getAllPages();
|
||||
// Result: ['index' => 'Home', 'about' => 'About Us', ...]
|
||||
|
||||
// Get a specific page's content
|
||||
$page = $api->getPage('about');
|
||||
// $page['title'], $page['content'], $page['path'], $page['layout'], $page['metadata']
|
||||
|
||||
// Check if a page exists
|
||||
if ($api->pageExists('contact')) {
|
||||
// ...
|
||||
}
|
||||
```
|
||||
|
||||
### Navigation
|
||||
|
||||
```php
|
||||
// Get menu structure
|
||||
$menu = $api->getMenu();
|
||||
// Nested array with 'title', 'path', 'url', 'children'
|
||||
```
|
||||
|
||||
### Configuration
|
||||
|
||||
```php
|
||||
// Get config value (dot notation)
|
||||
$title = $api->getConfig('site_title');
|
||||
$lang = $api->getConfig('language.default');
|
||||
$seoDesc = $api->getConfig('seo.description', 'Default description');
|
||||
```
|
||||
|
||||
### Current page
|
||||
|
||||
```php
|
||||
// Current page title
|
||||
$pageTitle = $api->getCurrentPageTitle();
|
||||
|
||||
// Current page path
|
||||
$pagePath = $api->getCurrentPagePath();
|
||||
|
||||
// Check if this is the homepage
|
||||
if ($api->isHomepage()) {
|
||||
echo 'Welcome!';
|
||||
}
|
||||
```
|
||||
|
||||
### URLs and language
|
||||
|
||||
```php
|
||||
// Build URL for a page
|
||||
$url = $api->buildUrl('about', 'en');
|
||||
|
||||
// Current language
|
||||
$lang = $api->getCurrentLanguage();
|
||||
|
||||
// Available languages
|
||||
$languages = $api->getAvailableLanguages();
|
||||
|
||||
// Site title
|
||||
$title = $api->getSiteTitle();
|
||||
```
|
||||
|
||||
### Translations and search
|
||||
|
||||
```php
|
||||
// Get translation
|
||||
$label = $api->t('home');
|
||||
|
||||
// Search results (if searching)
|
||||
if ($api->isSearching()) {
|
||||
$results = $api->getSearchResults();
|
||||
}
|
||||
```
|
||||
|
||||
### Example PHP content file
|
||||
|
||||
```php
|
||||
---
|
||||
title: Page Overview
|
||||
layout: content
|
||||
---
|
||||
<h1>All Pages</h1>
|
||||
<ul>
|
||||
<?php foreach ($api->getAllPages() as $path => $title): ?>
|
||||
<li><a href="<?= $api->buildUrl($path) ?>"><?= htmlspecialchars($title) ?></a></li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
```
|
||||
|
||||
## Analytics & Tracking
|
||||
|
||||
### MQTT Tracker
|
||||
|
||||
Reference in New Issue
Block a user