Fix guide template variable replacement and enhance documentation
- Fix template variable replacement in guide pages by removing {{}} brackets
- Escape code blocks in guide markdown to prevent template processing
- Completely rewrite guide documentation with comprehensive CMS features
- Add bilingual guide support (English/Dutch) with detailed examples
- Enhance CodePressCMS core with improved guide page handling
- Update template system with better layout and footer components
- Improve language files with additional translations
- Update configuration with enhanced theme and language settings
Resolves issue where guide pages were showing replaced template variables
instead of displaying them as documentation examples.
This commit is contained in:
114
plugins/HTMLBlock/HTMLBlock.php
Normal file
114
plugins/HTMLBlock/HTMLBlock.php
Normal file
@@ -0,0 +1,114 @@
|
||||
<?php
|
||||
|
||||
class HTMLBlock
|
||||
{
|
||||
private array $config;
|
||||
private ?CMSAPI $api = null;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->config = [
|
||||
'title' => 'HTML Block Plugin'
|
||||
];
|
||||
}
|
||||
|
||||
public function setAPI(CMSAPI $api): void
|
||||
{
|
||||
$this->api = $api;
|
||||
}
|
||||
|
||||
public function getSidebarContent(): string
|
||||
{
|
||||
$currentPage = $this->api ? $this->api->getCurrentPageTitle() : 'Onbekend';
|
||||
$isHomepage = $this->api ? $this->api->isHomepage() : false;
|
||||
$currentLang = $this->api ? $this->api->getCurrentLanguage() : 'nl';
|
||||
|
||||
$content = '
|
||||
<div class="card mb-3">
|
||||
<div class="card-header">
|
||||
<h5 class="mb-0">' . $this->config['title'] . '</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<p class="mb-2"><strong>Huidige pagina:</strong> ' . htmlspecialchars($currentPage) . '</p>
|
||||
<p class="mb-2"><strong>Taal:</strong> ' . strtoupper($currentLang) . '</p>
|
||||
<p class="mb-3"><strong>Homepage:</strong> ' . ($isHomepage ? 'Ja' : 'Nee') . '</p>';
|
||||
|
||||
// Add page-specific content
|
||||
if ($this->api) {
|
||||
$fileInfo = $this->api->getCurrentPageFileInfo();
|
||||
if ($fileInfo) {
|
||||
$content .= '
|
||||
<div class="alert alert-info mb-3">
|
||||
<small>
|
||||
<strong>Bestandsinfo:</strong><br>
|
||||
Aangemaakt: ' . htmlspecialchars($fileInfo['created']) . '<br>
|
||||
Gewijzigd: ' . htmlspecialchars($fileInfo['modified']) . '
|
||||
</small>
|
||||
</div>';
|
||||
}
|
||||
|
||||
// Add quick navigation
|
||||
$menu = $this->api->getMenu();
|
||||
if (!empty($menu)) {
|
||||
$content .= '
|
||||
<h6>Quick Navigation</h6>
|
||||
<ul class="list-unstyled mb-3">';
|
||||
|
||||
foreach ($menu as $item) {
|
||||
if ($item['type'] === 'file') {
|
||||
$url = $this->api->createUrl($item['path']);
|
||||
$content .= '<li><a href="' . htmlspecialchars($url) . '" class="text-decoration-none">📄 ' . htmlspecialchars($item['title']) . '</a></li>';
|
||||
}
|
||||
}
|
||||
|
||||
$content .= '</ul>';
|
||||
}
|
||||
}
|
||||
|
||||
$content .= '
|
||||
<hr>
|
||||
<h6>Actions</h6>
|
||||
<div class="d-grid gap-2">
|
||||
<button class="btn btn-sm btn-outline-primary" onclick="refreshContent()">
|
||||
<i class="bi bi-arrow-clockwise"></i> Ververs Content
|
||||
</button>
|
||||
<button class="btn btn-sm btn-outline-secondary" onclick="toggleSidebar()">
|
||||
<i class="bi bi-layout-sidebar"></i> Toggle Sidebar
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function refreshContent() {
|
||||
window.location.reload();
|
||||
}
|
||||
|
||||
function toggleSidebar() {
|
||||
const sidebar = document.getElementById("site-sidebar");
|
||||
const content = document.getElementById("site-content");
|
||||
if (sidebar.style.display === "none") {
|
||||
sidebar.style.display = "";
|
||||
content.classList.remove("col-12");
|
||||
content.classList.add("col-lg-9", "col-md-8");
|
||||
} else {
|
||||
sidebar.style.display = "none";
|
||||
content.classList.remove("col-lg-9", "col-md-8");
|
||||
content.classList.add("col-12");
|
||||
}
|
||||
}
|
||||
</script>';
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
public function getConfig(): array
|
||||
{
|
||||
return $this->config;
|
||||
}
|
||||
|
||||
public function setConfig(array $config): void
|
||||
{
|
||||
$this->config = array_merge($this->config, $config);
|
||||
}
|
||||
}
|
||||
100
plugins/HTMLBlock/README.md
Normal file
100
plugins/HTMLBlock/README.md
Normal file
@@ -0,0 +1,100 @@
|
||||
# HTMLBlock Plugin
|
||||
|
||||
Deze plugin toont een custom HTML blok in de sidebar met pagina-informatie en navigatie.
|
||||
|
||||
## Functies
|
||||
|
||||
- **Pagina informatie**: Toont huidige pagina titel en metadata
|
||||
- **Bestandsinfo**: Aanmaak- en wijzigingsdatums
|
||||
- **Dynamische navigatie**: Genereert quick links uit het menu
|
||||
- **Interactive controls**: Verversen en sidebar toggle
|
||||
- **Responsive**: Werkt op desktop en mobiel
|
||||
|
||||
## Installatie
|
||||
|
||||
1. Kopieer de `HTMLBlock` map naar `plugins/`
|
||||
2. De plugin wordt automatisch geladen
|
||||
|
||||
## Gebruik
|
||||
|
||||
De plugin wordt automatisch in de sidebar geladen en toont:
|
||||
|
||||
### Huidige Pagina Info
|
||||
- Pagina titel
|
||||
- Huidige taal
|
||||
- Homepage status
|
||||
|
||||
### Bestandsinformatie
|
||||
- Aanmaakdatum
|
||||
- Laatste wijziging
|
||||
- Bestandsgrootte
|
||||
|
||||
### Quick Navigation
|
||||
- Dynamische links uit het CMS menu
|
||||
- Automatische URL generatie
|
||||
|
||||
### Interactive Controls
|
||||
- **Ververs Content**: Herlaadt de huidige pagina
|
||||
- **Toggle Sidebar**: Toont/verbergt de sidebar
|
||||
|
||||
## Customization
|
||||
|
||||
De plugin content kan worden aangepast door de `getSidebarContent()` methode te wijzigen in `HTMLBlock.php`.
|
||||
|
||||
### Voorbeeld Custom Content
|
||||
|
||||
```php
|
||||
public function getSidebarContent(): string
|
||||
{
|
||||
$currentPage = $this->api ? $this->api->getCurrentPageTitle() : 'Onbekend';
|
||||
|
||||
return '
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<h5>Mijn Custom Block</h5>
|
||||
<p>Huidige pagina: ' . htmlspecialchars($currentPage) . '</p>
|
||||
</div>
|
||||
</div>';
|
||||
}
|
||||
```
|
||||
|
||||
## API Integration
|
||||
|
||||
De plugin maakt gebruik van de CMS API voor:
|
||||
|
||||
- `getCurrentPageTitle()` - Huidige pagina titel
|
||||
- `getCurrentLanguage()` - Huidige taal
|
||||
- `isHomepage()` - Check of homepage
|
||||
- `getCurrentPageFileInfo()` - Bestandsinformatie
|
||||
- `getMenu()` - Menu structuur
|
||||
- `createUrl($page, $lang)` - URL generatie
|
||||
|
||||
## Styling
|
||||
|
||||
De plugin gebruikt Bootstrap 5 classes:
|
||||
- `card`, `card-header`, `card-body` voor kaarten
|
||||
- `btn`, `btn-outline-primary` voor knoppen
|
||||
- `list-unstyled` voor navigatie
|
||||
|
||||
## JavaScript
|
||||
|
||||
De plugin bevat JavaScript voor:
|
||||
- Pagina verversen
|
||||
- Sidebar toggle functionaliteit
|
||||
- Dynamische content updates
|
||||
|
||||
## Development
|
||||
|
||||
De plugin is een goed voorbeeld voor:
|
||||
- API integratie
|
||||
- Dynamic content generatie
|
||||
- User interface components
|
||||
- Responsive design
|
||||
|
||||
## Bestandsstructuur
|
||||
|
||||
```
|
||||
HTMLBlock/
|
||||
├── HTMLBlock.php # Hoofd plugin bestand
|
||||
└── README.md # Deze documentatie
|
||||
```
|
||||
Reference in New Issue
Block a user