Merge development v2.6.0 into main
Resolved conflicts by taking development (v2.6.0) version for all files. Removed statistics.twig (replaced by Statistics plugin).
This commit is contained in:
@@ -1,7 +1,5 @@
|
||||
# Layouts
|
||||
|
||||
Layouts define the page structure (left sidebar, full width, etc.). Layouts are defined in `theme.json` and chosen via frontmatter in content files.
|
||||
|
||||
## Choosing a layout in content
|
||||
|
||||
```markdown
|
||||
@@ -16,58 +14,19 @@ Content...
|
||||
|
||||
## Layouts in theme.json
|
||||
|
||||
Layouts are defined in the `template` mapping. The `config.default_template` is the fallback for pages without a `layout:` frontmatter or with an unknown layout:
|
||||
|
||||
```json
|
||||
{
|
||||
"config": {
|
||||
"default_template": "full_content"
|
||||
},
|
||||
"template": {
|
||||
"full_content": "full_content.twig",
|
||||
"left_sidebar": "left_sidebar.twig",
|
||||
"right_sidebar": "right_sidebar.twig",
|
||||
"custom1": "custom1.twig",
|
||||
"guide": "guide.twig"
|
||||
}
|
||||
"config": {
|
||||
"default_template": "full_content"
|
||||
},
|
||||
"template": {
|
||||
"full_content": "full_content.twig",
|
||||
"left_sidebar": "left_sidebar.twig",
|
||||
"right_sidebar": "right_sidebar.twig",
|
||||
"custom1": "custom1.twig",
|
||||
"guide": "guide.twig"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Layout template
|
||||
|
||||
A layout template extends `base.twig` and fills the `content` block:
|
||||
|
||||
```twig
|
||||
{% extends 'base.twig' %}
|
||||
|
||||
{% block content %}
|
||||
<div class="container">
|
||||
{{ content|raw }}
|
||||
</div>
|
||||
{% endblock %}
|
||||
```
|
||||
|
||||
## Layouts with sidebar
|
||||
|
||||
Layouts with a sidebar can show plugin content:
|
||||
|
||||
```twig
|
||||
{% extends 'base.twig' %}
|
||||
|
||||
{% block content %}
|
||||
<div class="row">
|
||||
<main class="col-md-8">
|
||||
{{ content|raw }}
|
||||
</main>
|
||||
<aside class="col-md-4">
|
||||
{{ sidebar_content|raw }}
|
||||
</aside>
|
||||
</div>
|
||||
{% endblock %}
|
||||
```
|
||||
|
||||
If a page has no plugins or the layout has no sidebar, `sidebar_content` is empty.
|
||||
|
||||
## Guide layout
|
||||
|
||||
The `guide` layout (`guide.twig`) is special for guides. It injects the Navigation plugin into the sidebar for sidebar navigation. Automatically used for pages in the `guide/` folder.
|
||||
Unknown layouts in frontmatter fall back to `config.default_template`.
|
||||
@@ -22,4 +22,5 @@ Create basic files:
|
||||
- `full_content.twig`
|
||||
- `partials/header.twig`
|
||||
- `partials/footer.twig`
|
||||
- `scss/theme.scss`
|
||||
- `scss/theme.scss`
|
||||
- `guide.twig` (if guide support is needed)
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
1. Go to **Admin** → **Theme**
|
||||
2. Click **Compile SCSS** for your theme
|
||||
3. CSS is generated in `assets/css/theme.css`
|
||||
3. CSS is generated in `assets/css_compiled/theme.css`
|
||||
|
||||
## SCSS example
|
||||
|
||||
|
||||
@@ -2,45 +2,24 @@
|
||||
|
||||
```json
|
||||
{
|
||||
"title": "My Theme",
|
||||
"config": {
|
||||
"default_template": "full_content"
|
||||
},
|
||||
"template": {
|
||||
"full_content": "full_content.twig",
|
||||
"left_sidebar": "left_sidebar.twig",
|
||||
"right_sidebar": "right_sidebar.twig",
|
||||
"custom1": "custom1.twig",
|
||||
"guide": "guide.twig"
|
||||
}
|
||||
"title": "My Theme",
|
||||
"config": {
|
||||
"default_template": "full_content"
|
||||
},
|
||||
"template": {
|
||||
"full_content": "full_content.twig",
|
||||
"left_sidebar": "left_sidebar.twig",
|
||||
"right_sidebar": "right_sidebar.twig",
|
||||
"custom1": "custom1.twig",
|
||||
"guide": "guide.twig"
|
||||
},
|
||||
"header_color": "#0a369d"
|
||||
}
|
||||
```
|
||||
|
||||
## Fields
|
||||
|
||||
- `title` — Display name in admin
|
||||
- `config.default_template` — Default layout for pages without a `layout:` frontmatter (fallback for unknown layouts)
|
||||
- `template` — Mapping from layout name to `.twig` file
|
||||
|
||||
## Template mapping
|
||||
|
||||
The `template` mapping defines which layouts are available. Each key is a layout name, each value is the `.twig` file:
|
||||
|
||||
| Layout name | Twig file | Description |
|
||||
|-------------|-----------|-------------|
|
||||
| `full_content` | `full_content.twig` | Full width, no sidebar |
|
||||
| `left_sidebar` | `left_sidebar.twig` | Sidebar on the left |
|
||||
| `right_sidebar` | `right_sidebar.twig` | Sidebar on the right |
|
||||
| `custom1` | `custom1.twig` | Custom layout |
|
||||
| `guide` | `guide.twig` | Guide with sidebar (Navigation plugin) |
|
||||
|
||||
## Layout selection
|
||||
|
||||
- Layouts are chosen via the frontmatter `layout:` key in content files
|
||||
- Unknown layouts fall back to `config.default_template`
|
||||
- `ThemeManager::getTemplates()` returns the template mapping
|
||||
- `ThemeManager::getConfig()` returns the config section (including `default_template`)
|
||||
|
||||
## Guide layout
|
||||
|
||||
The `guide` layout is special for guides. `getGuidePage()` in `CodePressCMS.php` automatically injects the Navigation plugin into the metadata for sidebar navigation.
|
||||
- `title` - Display name in admin
|
||||
- `config.default_template` - Default layout for new pages
|
||||
- `template` - Mapping of layout names to .twig files
|
||||
- `header_color` - (optional) Admin sidebar color, defaults to `#0a369d`
|
||||
Reference in New Issue
Block a user