# 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 '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 '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
{{ content }}
— = $block->setting('person') ?>"= $block->setting('quote_text') ?>"