add Docsify-based documentation site

Add a complete documentation site for Plugi with the following pages:

- Readme.md: project overview, quick start, and key features
- GettingStarted.md: installation guide, requirements, and first steps
- Configuration.md: full reference for .env and config.php settings
- Themes.md: theme structure, blocks, layouts, and asset compilation
- Extensions.md: extension architecture, routes, blocks, and admin pages

Also add index.html (Docsify entry point), _sidebar.md (navigation), favicon.ico, and .nojekyll to prevent GitHub Pages from interfering.
This commit is contained in:
2026-11-23 19:28:06 +01:00
commit 07379d9d03
9 changed files with 1069 additions and 0 deletions
View File
+202
View File
@@ -0,0 +1,202 @@
# Configuration
Plugi is configured through two files:
- **`.env`** — Environment variables for database connection and application stage.
- **`config.php`** — PHP array that controls all framework behavior, modules, themes, and extensions.
## The `.env` File
The `.env` file is loaded by `EnvLoader` at boot time. It must exist in the project root. Typical contents:
```ini
DB_HOST=mysql
DB_NAME=plugi
DB_USER=plugi
DB_PASSWORD=plugi
STAGE=development
```
| Variable | Description | Default |
|----------------|----------------------------------------------|------------------|
| `DB_HOST` | MySQL host (e.g., `localhost` or `mysql`) | `mysql` |
| `DB_NAME` | Database name | `plugi` |
| `DB_USER` | Database user | `plugi` |
| `DB_PASSWORD` | Database password | `plugi` |
| `STAGE` | Application stage (`development` or `production`) | `development` |
Setting `STAGE=production` disables PHP error display in `index.php`.
## The `config.php` File
Copy `config.dist.php` to `config.php` and adjust the settings. The configuration is a PHP array with the following sections:
### General Settings
```php
'general' => [
'language' => 'en',
'assets_url' => '/plugi-core/dist',
'uploads_url' => '/uploads'
],
```
| Key | Description |
|----------------|--------------------------------------------------|
| `language` | Default language code (e.g., `en`, `de`, `fr`). Theme and extension translations are loaded for this language. |
| `assets_url` | Public URL path to the Plugi core assets (JS, CSS, images). |
| `uploads_url` | Public URL path to the uploads directory. |
### Storage Settings
```php
'storage' => [
'use_database' => true,
'uploads_folder' => __DIR__ . '/uploads'
],
```
| Key | Description |
|--------------------|----------------------------------------------------------|
| `use_database` | Set to `true` to use MySQL for storing pages, settings, and uploads metadata. |
| `uploads_folder` | Absolute filesystem path where uploaded files are stored. |
### Auth Settings
```php
'auth' => [
'use_login' => true,
'class' => Plugi\Modules\Auth\Auth::class,
'url' => '/admin/auth',
],
```
| Key | Description |
|---------------|-----------------------------------------------------------------------------|
| `use_login` | Enable or disable the built-in authentication module. |
| `class` | Fully qualified class name implementing `AuthContract`. |
| `url` | URL prefix for auth endpoints (login/logout). |
The default `Auth` class checks credentials stored in the database settings table. Change the admin username and password from the admin panel after first login.
### Website Manager Settings
```php
'website_manager' => [
'use_website_manager' => true,
'class' => Plugi\Modules\WebsiteManager\WebsiteManager::class,
'url' => '/admin'
],
```
| Key | Description |
|---------------------------|-----------------------------------------------------------------------|
| `use_website_manager` | Enable or disable the admin dashboard. |
| `class` | Class implementing `WebsiteManagerContract`. |
| `url` | URL prefix for the admin panel. |
### Page Builder Settings
```php
'pagebuilder' => [
'class' => Plugi\Modules\GrapesJS\PageBuilder::class,
'url' => '/admin/pagebuilder',
'actions' => [
'back' => '/admin'
]
],
```
| Key | Description |
|-------------|---------------------------------------------------------------|
| `class` | Class implementing `PageBuilderContract` (GrapesJS-based by default). |
| `url` | URL prefix for the page builder. |
| `actions` | Named action URLs, e.g., `back` returns to the admin panel. |
### Page Settings
```php
'page' => [
'class' => Plugi\Page::class,
'table' => 'pages',
'translation' => [
'class' => Plugi\PageTranslation::class,
'table' => 'page_translations',
'foreign_key' => 'page_id',
]
],
```
| Key | Description |
|-----------------------|---------------------------------------------------------------|
| `class` | Class implementing `PageContract`. |
| `table` | Database table name for pages. |
| `translation.class` | Class implementing `PageTranslationContract`. |
| `translation.table` | Database table name for page translations (multilingual support). |
| `translation.foreign_key` | Foreign key column linking translations to pages. |
### Cache Settings
```php
'cache' => [
'enabled' => false,
'folder' => __DIR__ . '/cache',
'class' => Plugi\Cache::class
],
```
| Key | Description |
|-------------|-----------------------------------------------------------------------------|
| `enabled` | Enable page caching. Cached pages skip block parsing on subsequent requests. |
| `folder` | Filesystem path for cache files. |
| `class` | Class implementing `CacheContract`. |
A page is cached unless it contains a block with caching disabled. The cache is automatically cleared when a page is saved in the page builder. You can also force a cache refresh by appending `?refresh_cache` to the URL.
### Theme Settings
```php
'theme' => [
'class' => Plugi\Theme::class,
'folder' => __DIR__ . '/themes',
'folder_url' => '/themes',
'active_theme' => 'theme-one'
],
```
| Key | Description |
|------------------|---------------------------------------------------------------|
| `class` | Class implementing `ThemeContract`. |
| `folder` | Filesystem path to the themes directory. |
| `folder_url` | Public URL path to the themes directory. |
| `active_theme` | Slug of the active theme (matches a folder name in `themes/`). |
### Router Settings
```php
'router' => [
'class' => Plugi\Modules\Router\DatabasePageRouter::class
],
```
| Key | Description |
|-----------|---------------------------------------------------------------|
| `class` | Class implementing `RouterContract` that resolves URLs to pages. |
### Class Replacements
```php
'class_replacements' => [
// Plugi\UploadedFile::class => Alternative\UploadedFile::class
],
```
Map a core class namespace to an alternative implementation. This allows overriding specific classes while extending the originals. Example:
```php
'class_replacements' => [
Plugi\UploadedFile::class => My\App\CustomUploadedFile::class,
],
```
> **Important:** When overriding a class, always extend the original class.
+316
View File
@@ -0,0 +1,316 @@
# Extensions
Extensions (also called plugins) allow you to add functionality to Plugi without modifying the core. They can register routes, blocks, layouts, backend admin pages, assets, settings, and HTML injection points.
## How Extensions Work
When Plugi boots, it scans the `extensions/` directory. For each subdirectory that contains both an `extension.php` and a `config.php` file, it loads the extension and registers its features.
## Extension Structure
A minimal extension looks like this:
```
extensions/
└── my-extension/
├── extension.php # Bootstrap — registers routes, blocks, etc.
├── config.php # Metadata and configuration
├── routes/ # Route handler files (optional)
├── blocks/ # Theme blocks provided by the extension (optional)
├── admin/ # Admin panel files (optional)
├── assets/ # CSS, JS, images (optional)
└── lang/ # Translation files (optional)
```
## The `config.php` File
Every extension must have a `config.php` that returns a configuration array:
```php
<?php
return [
'title' => 'My Extension',
'author' => 'Your Name',
'identifier' => 'my-extension',
'licence' => 'MIT',
'version' => '1.0.0',
];
```
### Optional Config Keys
| Key | Description |
|--------------|---------------------------------------------------------------|
| `settings` | Array of setting definitions for the admin panel (see below). |
| `assets` | Array of CSS/JS assets to inject on public or admin pages. |
| `tables` | Database tables the extension requires (see below). |
### Extension Settings
Define settings that appear in the admin panel:
```php
'settings' => [
[
'name' => 'email',
'label' => 'Notification Email',
'default' => 'admin@example.com',
'type' => 'text',
],
[
'name' => 'enabled',
'label' => 'Enable Feature',
'default' => 'true',
'type' => 'toggle',
],
],
```
Supported types: `text`, `toggle`, and others depending on the admin UI.
### Extension Assets
Register CSS and JS files that should be loaded on specific pages:
```php
'assets' => [
[
'src' => '/assets/dist.css',
'type' => 'style',
'location' => 'header',
],
[
'src' => '/assets/app.js',
'type' => 'script',
'location' => 'footer',
],
],
```
Valid locations: `header`, `footer`, `admin-header`, `admin-footer`.
### Extension Database Tables
Declare tables that the extension needs. Plugi will create them on first run:
```php
'tables' => [
'entries' => [
'columns' => [
'formId' => 'int NOT NULL',
'data' => 'longtext NOT NULL',
'created' => 'timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP',
],
'uniqueKeys' => [],
],
'definitions' => [
'columns' => [
'name' => 'varchar(255) NOT NULL',
'fields' => 'longtext NOT NULL',
'finishers' => 'longtext NOT NULL',
],
'uniqueKeys' => [
'name' => ['name'],
],
],
],
```
## The `extension.php` File
This file is executed at boot time. Use the `Plugi\Extensions` class to register features:
```php
<?php
use Plugi\Extensions;
// Register routes
Extensions::addRoutes([
'/my-route' => dirname(__FILE__) . '/routes/my-route.php',
]);
// Register blocks
Extensions::addBlocks([
'my-block' => __DIR__ . '/blocks/my-block',
]);
// Register layouts
Extensions::addLayouts([
'my-layout' => __DIR__ . '/layouts/my-layout',
]);
// Register a backend admin page
Extensions::registerBackend('my-extension', [
'title' => 'My Extension',
'include' => __DIR__ . '/admin/index.php',
'icon' => '<i class="ph ph-circles-three-plus"></i>',
]);
// Register assets programmatically
Extensions::registerAsset('/extensions/my-extension/app.js', 'script', 'footer');
// Register HTML blocks injected at specific locations
Extensions::registerHtmlBlock('<script>console.log("loaded");</script>', 'head');
```
## Routes
Extensions can define custom routes. Each route maps a URL path to a PHP file:
```php
Extensions::addRoutes([
'/sitemap.xml' => dirname(__FILE__) . '/routes/sitemap.php',
]);
```
The route file is a regular PHP script that has access to all Plugi globals and classes. Return `continue` from the route file to let Plugi continue processing the request:
```php
<?php
// routes/example.php
echo "Hello from extension!";
return 'continue'; // Let Plugi continue with normal page rendering
```
If the route file does not return `continue`, Plugi stops processing and the route handles the entire response.
## Blocks
Extensions can provide blocks that appear in the page builder's block library. A block directory contains the same files as a theme block:
```
blocks/
└── my-block/
├── config.php # Block configuration (title, icon, settings)
├── view.html # HTML template (or view.php for PHP blocks)
└── script.js # Optional JavaScript
```
Block `config.php` example:
```php
<?php
return [
'title' => 'My Block',
'category' => 'Custom',
'icon' => 'fa fa-star',
'settings' => [
'message' => [
'label' => 'Message',
'type' => 'text',
'value' => 'Hello World',
],
],
];
```
In `view.html`, access settings with the `$block` variable:
```html
<div class="my-block">
<p><?= $block->setting('message') ?></p>
</div>
```
For PHP blocks, use `view.php` instead. The `$block` object provides:
- `$block->setting('key')` — Get a block setting value.
- `$block->get('config_key')` — Get a value from `config.php`.
## Backend Admin Pages
Register a backend page that appears in the admin panel sidebar:
```php
Extensions::registerBackend('my-extension', [
'title' => 'My Extension',
'include' => __DIR__ . '/admin/index.php',
'icon' => '<i class="ph ph-circles-three-plus"></i>',
]);
```
The `include` file is a PHP view rendered inside the admin panel. It has access to all Plugi classes and helpers.
## Translations
Place translation files in the `lang/` directory:
```
lang/
├── en.php
└── de.php
```
Each file returns an associative array:
```php
<?php
// lang/en.php
return [
'my-extension' => [
'welcome' => 'Welcome!',
'save' => 'Save',
],
];
```
Use translations in your code:
```php
phpb_trans('my-extension.welcome')
```
## Helper Functions
The following global helper functions are available in extension code:
| Function | Description |
|---------------------------------|--------------------------------------------------|
| `phpb_config('key')` | Get a config value using dot notation. |
| `phpb_trans('key')` | Get a translated string. |
| `phpb_e($string)` | Escape output for HTML. |
| `phpb_current_language()` | Get the current language code. |
| `phpb_current_relative_url()` | Get the current request URL. |
| `phpb_redirect($url)` | Redirect to a URL. |
| `phpb_instance($key, $args=[])` | Create an instance of a configured class. |
| `phpb_asset($path)` | Generate a URL to a Plugi core asset. |
| `phpb_theme_asset($path)` | Generate a URL to a theme asset. |
## Example: Sitemap Extension
The `plugi-ext-sitemap` extension demonstrates a minimal extension:
**config.php:**
```php
<?php
return [
'title' => 'Sitemap',
'author' => 'Paul Spenke',
'identifier' => 'sitemap',
'licence' => 'MIT',
'version' => '1.0.0',
];
```
**extension.php:**
```php
<?php
use Plugi\Extensions;
Extensions::addRoutes([
'/sitemap.xml' => dirname(__FILE__) . '/routes/sitemap.php'
]);
```
**routes/sitemap.php:**
```php
<?php
// Generate and output XML sitemap
header('Content-Type: application/xml');
// ... sitemap generation logic
```
## Example: Form Extension
The `plugi-ext-form` extension demonstrates a full-featured extension with routes, blocks, admin pages, settings, and database tables. See the `extensions/plugi-ext-form/` directory for the complete source.
+117
View File
@@ -0,0 +1,117 @@
# Getting Started
This guide will help you get Plugi up and running on your local machine or server.
## Requirements
- **PHP 8.2** or higher
- **MySQL 8.0** or higher
- **Apache** or **Nginx** web server
- **PDO MySQL** extension enabled
## Installation
### Option 1: Manual Installation
1. **Download Plugi** and upload it to the webroot directory of your website.
2. **Create the `.env` file** by copying `.env.example` (if available) or creating one with the following variables:
```ini
DB_HOST=mysql
DB_NAME=plugi
DB_USER=plugi
DB_PASSWORD=plugi
STAGE=development
```
Adjust the database credentials to match your MySQL server.
3. **Create the config file** by copying `config.dist.php` to `config.php`:
```bash
cp config.dist.php config.php
```
4. **Edit `config.php`** and update the settings as needed. At a minimum, change the default login credentials in the `auth` section.
5. **Set up the database**. On first access, Plugi will create the required tables automatically. If the database schema changes in a future version, the admin panel will prompt you to update it.
6. **Access the admin panel** by navigating to `/admin` on your website and logging in with the credentials you set in `config.php` (defaults are `admin` / `admin`).
### Option 2: Docker
The quickest way to get started is with Docker Compose:
1. **Clone or download** the Plugi repository.
2. **Create the `.env` file** with your environment variables (see above).
3. **Create `config.php`** from `config.dist.php`:
```bash
cp config.dist.php config.php
```
4. **Start the services**:
```bash
docker-compose up -d
```
This will start three services:
- **Web** (PHP 8.2 + Apache) on port `63000`
- **MySQL 8.0** database
- **Adminer** (database management) on port `63001`
5. **Open your browser** and navigate to `http://localhost:63000/admin` to access the admin panel.
## First Steps
After logging in, you will see the **Website Manager** dashboard. From here you can:
- **Create pages** — Add new pages with custom routes and titles.
- **Edit pages** — Use the drag-and-drop **Page Builder** (powered by GrapesJS) to design your pages visually.
- **Manage blocks** — Drag blocks from the block library onto your pages. Blocks are defined by your active theme.
- **Configure settings** — Adjust general settings, select a theme, and manage extensions from the admin panel.
- **Manage menus** — Create and assign navigation menus.
- **Upload files** — Manage uploaded assets from the Files tab.
## Project Structure
A typical Plugi project has the following structure:
```
project-root/
├── index.php # Entry point
├── config.php # Configuration (copied from config.dist.php)
├── .env # Environment variables
├── plugi-core/ # Core framework files
├── extensions/ # Extensions (plugins)
│ ├── plugi-ext-form/ # Form extension
│ └── plugi-ext-sitemap/ # Sitemap extension
├── themes/ # Themes
│ └── theme-one/ # Active theme
│ ├── blocks/ # Theme blocks
│ ├── layouts/ # Page layouts
│ ├── pages/ # Static pages (e.g. 404.php)
│ └── dist/ # Compiled CSS/JS
├── uploads/ # User-uploaded files
└── docs/ # Documentation
```
## Production Checklist
Before deploying to production:
1. Set `STAGE=production` in your `.env` file to disable error reporting.
2. Change the default admin credentials in `config.php`.
3. Enable caching in `config.php` (`cache.enabled => true`) for better performance.
4. Ensure the `uploads/` directory is writable but not executable.
5. Consider using `.htaccess` (Apache) or Nginx config to serve `/uploads` directly, bypassing PHP for faster file delivery.
## Next Steps
- Learn how to [configure](Configuration.md) Plugi in detail.
- Discover how to create custom [themes](Themes.md).
- Build your own [extensions](Extensions.md) to add functionality.
+67
View File
@@ -0,0 +1,67 @@
![Plugi](https://gitea.spenke-nordic.com/deepDiverPaul/plugi/raw/branch/main/plugi-core/dist/images/plugi-banner.png)
# Plugi
A lightweight PHP-based website builder with a drag-and-drop page editor, theming system, and extensible plugin architecture.
> A fork of [PHPagebuilder](https://github.com/HansSchouten/PHPagebuilder) by [Hans Schouten](https://github.com/HansSchouten).
## Quick Start
Get up and running in minutes:
1. **Download** Plugi and upload it to your webroot.
2. **Create** a `.env` file with your database credentials.
3. **Copy** `config.dist.php` to `config.php` and adjust settings.
4. **Navigate** to `/admin` and log in with the default credentials (`admin` / `admin`).
Or use Docker for a quick local setup:
```bash
docker-compose up -d
```
Then open `http://localhost:63000/admin` in your browser.
## Key Features
- **Page Builder** — Visual drag-and-drop editor powered by GrapesJS for designing pages without code.
- **Theming System** — Create custom themes with reusable blocks, layouts, and static pages.
- **Extensions** — Extend functionality with plugins that add routes, admin pages, blocks, and more.
- **Multilingual** — Built-in translation support for pages, themes, and extensions.
- **Caching** — Optional page caching for production performance.
- **Database-Driven** — All content stored in MySQL with automatic schema management.
## Documentation
| Section | Description |
|---------|-------------|
| [Getting Started](GettingStarted.md) | Installation, requirements, and first steps. |
| [Configuration](Configuration.md) | Full reference for `.env` and `config.php` settings. |
| [Themes](Themes.md) | How to create and structure custom themes with blocks and layouts. |
| [Extensions](Extensions.md) | How to build extensions that add routes, admin pages, blocks, and more. |
## Requirements
- **PHP 8.2** or higher
- **MySQL 8.0** or higher
- **Apache** or **Nginx** web server
- **PDO MySQL** extension enabled
## Project Structure
```
project-root/
├── index.php # Entry point
├── config.php # Configuration
├── .env # Environment variables
├── plugi-core/ # Core framework
├── extensions/ # Extensions (plugins)
├── themes/ # Themes
├── uploads/ # User-uploaded files
└── docs/ # Documentation
```
## License
Plugi is open-source software under MIT License.
+334
View File
@@ -0,0 +1,334 @@
# Themes
Themes define the visual appearance and building blocks of your Plugi website. Each theme contains **blocks** (reusable page components), **layouts** (page templates), static pages, and compiled assets.
## Theme Structure
A theme lives in the `themes/` directory as a subfolder. The folder name is the theme's slug:
```
themes/
└── theme-one/
├── config.php # Theme metadata and settings
├── preview.jpg # Theme preview image (shown in admin)
├── blocks/ # Reusable page components
│ ├── paragraph/
│ │ ├── config.php
│ │ └── view.html
│ ├── quote/
│ │ ├── config.php
│ │ └── view.php
│ └── ...
├── layouts/ # Page layout templates
│ └── master/
│ ├── config.php
│ └── view.php
├── pages/ # Static pages (e.g., 404.php)
├── translations/ # Theme-specific translations
│ ├── en.php
│ └── de.php
├── dist/ # Compiled CSS and JS
│ ├── style.css
│ └── script.js
├── src/ # Source files (Sass, TypeScript, etc.)
└── package.json # Node.js dependencies for building assets
```
## Theme Configuration
The `config.php` file defines theme metadata and optional settings:
```php
<?php
return [
'title' => 'Theme One',
'author' => 'Your Name',
'licence' => 'MIT',
'version' => '1.0.0',
'settings' => [
[
'name' => 'primaryColor',
'label' => 'Primary Color',
'default' => '#3b82f6',
'type' => 'text',
],
],
];
```
| Key | Description |
|-------------|---------------------------------------------------------------|
| `title` | Display name of the theme. |
| `author` | Theme author name. |
| `licence` | License identifier. |
| `version` | Semantic version string. |
| `settings` | Array of setting definitions available in the admin panel. |
## Blocks
Blocks are the building blocks of your pages. Each block is a subfolder inside `blocks/` and contains at minimum a `config.php` and a view file.
### Block Folders
Blocks can be organized into subfolders:
| Subfolder | Purpose |
|-----------------|------------------------------------------------------------|
| (root) | Default blocks, always available. |
| `archived/` | Deprecated or archived blocks. |
| `elements/` | Reusable UI elements. |
| `php/` | Blocks that require PHP execution. |
### Block Files
A block directory can contain the following files:
| File | Required | Description |
|-------------------------|----------|------------------------------------------------------------|
| `config.php` | Yes | Block configuration (title, icon, settings, category). |
| `view.html` | One of | HTML template for the block. |
| `view.php` | these | PHP template for the block (enables PHP execution). |
| `controller.php` | No | Custom controller class for the block. |
| `model.php` | No | Custom model class for the block. |
| `script.js` | No | JavaScript executed on the public page. |
| `builder-script.js` | No | JavaScript executed in the page builder preview. |
### Block Configuration
```php
<?php
return [
'title' => 'Quote',
'category' => 'General',
'icon' => 'fa fa-quote-left',
'hidden' => false, // Hide from block library if true
'cache' => true, // Allow caching (default: true)
'cache_lifetime' => 3600, // Cache TTL in seconds
'wrapper' => 'div', // Wrapper element for PHP blocks
'whitelist' => [], // Domain whitelist (empty = all domains)
'settings' => [
'person' => [
'label' => 'Person Name',
'type' => 'text',
'placeholder' => 'John Doe',
'value' => 'Michael Gough',
],
],
];
```
### Block Views
**HTML blocks** (`view.html`) are rendered as-is. Use `{{ setting_name }}` syntax for settings:
```html
<div class="paragraph">
<p>{{ content }}</p>
</div>
```
**PHP blocks** (`view.php`) have full PHP access. The `$block` variable provides:
```php
<section class="quote-block">
<blockquote>
<p>"<?= $block->setting('quote_text') ?>"</p>
</blockquote>
<cite>— <?= $block->setting('person') ?></cite>
</section>
```
Available methods on `$block`:
- `$block->setting('key')` — Get a setting value.
- `$block->get('config_key')` — Get a value from `config.php`.
- `$block->get('config.nested.key')` — Dot notation for nested config.
### Block Controllers and Models
For complex blocks, you can add a controller and/or model:
**controller.php:**
```php
<?php
namespace ThemeOne\Blocks\Quote;
use Plugi\Modules\GrapesJS\Block\BaseController;
class Controller extends BaseController
{
public function index()
{
// Custom logic before rendering the view
$this->view['extra_data'] = 'hello';
}
}
```
**model.php:**
```php
<?php
namespace ThemeOne\Blocks\Quote;
use Plugi\Modules\GrapesJS\Block\BaseModel;
class Model extends BaseModel
{
// Custom data handling
}
```
The namespace is auto-generated from the theme and block folder names, or you can set it explicitly in `config.php`:
```php
'namespace' => 'MyCustom\Namespace',
```
## Layouts
Layouts define the overall page structure (header, navigation, footer). Each layout is a subfolder inside `layouts/`.
### Layout Files
| File | Required | Description |
|----------------|----------|------------------------------------------------------------|
| `config.php` | No | Layout configuration. |
| `view.php` | Yes | PHP template for the layout. |
### Layout View
The layout view receives two variables:
- `$body` — The rendered page content (blocks).
- `$page` — The current page object.
Example `view.php`:
```php
<!doctype html>
<html lang="<?= phpb_current_language() ?>">
<head>
<meta charset="utf-8">
<title><?= phpb_e($page->getTranslation('meta_title')) ?></title>
<link href="<?= phpb_theme_asset('dist/style.css') ?>" rel="stylesheet">
<?= \Plugi\Extensions::getHeaderAssets() ?>
</head>
<body>
<header>
<!-- Navigation -->
</header>
<main>
<?= $body ?>
</main>
<footer>
<!-- Footer content -->
</footer>
<script src="<?= phpb_theme_asset('dist/script.js') ?>"></script>
<?= \Plugi\Extensions::getFooterAssets() ?>
</body>
</html>
```
### Available Variables in Layouts
| Variable | Description |
|-------------|------------------------------------------------|
| `$body` | Rendered page content (all blocks combined). |
| `$page` | Current `Page` object with translation methods.|
### Page Methods
- `$page->getTranslation('field')` — Get a translated field value.
- `$page->get('field')` — Get a page field value.
- `$page->get('type')` — Get page type (e.g., `redirect`).
## Static Pages
Place static PHP pages in the `pages/` directory. Plugi looks for special pages here:
- `404.php` — Custom 404 error page.
## Translations
Theme translations go in the `translations/` directory:
```php
<?php
// translations/en.php
return [
'theme' => [
'welcome' => 'Welcome to our site',
'footer' => 'All rights reserved',
],
];
```
Translations are merged with core translations and can be overridden per language.
## Assets
Themes typically use a build pipeline (Webpack, Vite, etc.) to compile source files into the `dist/` directory:
```
theme-one/
├── src/
│ ├── styles/
│ │ └── main.scss
│ └── scripts/
│ └── main.ts
├── dist/
│ ├── style.css # Compiled CSS
│ └── script.js # Compiled JS
└── package.json # Build dependencies
```
Reference compiled assets in your views:
```php
<link href="<?= phpb_theme_asset('dist/style.css') ?>" rel="stylesheet">
<script src="<?= phpb_theme_asset('dist/script.js') ?>"></script>
```
## Creating a New Theme
1. **Create a folder** inside `themes/` with your theme's slug:
```bash
mkdir themes/my-theme
```
2. **Add `config.php`**:
```php
<?php
return [
'title' => 'My Theme',
'author' => 'Your Name',
'licence' => 'MIT',
'version' => '1.0.0',
];
```
3. **Create a layout** in `layouts/master/view.php` with your HTML structure.
4. **Add blocks** in `blocks/` with `config.php` and view files.
5. **Set as active** in `config.php`:
```php
'theme' => [
'active_theme' => 'my-theme',
],
```
6. **Add a preview image** (`preview.jpg`) so the theme appears in the admin panel's theme selector.
## Switching Themes
You can switch themes from the admin panel (Settings → Theme) or by changing `theme.active_theme` in `config.php`. The value must match a folder name inside `themes/`.
## Extension Blocks and Layouts
Extensions can also provide blocks and layouts that are merged with the active theme's blocks and layouts. See the [Extensions](Extensions.md) documentation for details.
+10
View File
@@ -0,0 +1,10 @@
- Plugi Core
- [Home](Readme.md)
- [Getting Started](GettingStarted.md)
- [Configuration](Configuration.md)
- Customization
- [Themes](Themes.md)
- [Extensions](Extensions.md)
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

+23
View File
@@ -0,0 +1,23 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Document</title>
<meta name="description" content="Description">
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/docsify@5/dist/themes/core.min.css">
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/docsify@5/dist/themes/addons/vue.min.css">
</head>
<body>
<div id="app"></div>
<script>
window.$docsify = {
name: 'Plugi',
repo: 'https://gitea.spenke-nordic.com/deepDiverPaul/plugi',
loadSidebar: true,
}
</script>
<!-- Docsify resource -->
<script src="//cdn.jsdelivr.net/npm/docsify@5"></script>
</body>
</html>