Bu geliştirici başvurusu şimdilik yalnızca İngilizcedir; kod örnekleri ve adlar iki dilde de aynıdır.
This guide is the complete reference for building front-end themes for IronCMS. It covers the theme package format, the theme.json manifest, the template API, every variable your templates receive, the security gate your package must pass, and how themes are packaged, signed and distributed.
The shipped Default theme (themes/default) follows every rule in this document and is reproducible from it — when in doubt, read this guide first and the Default theme second.
How IronCMS themes work
IronCMS's theme engine (internally named Loom) renders the entire public site through the active theme. Three principles shape everything below:
- Themes are view-only. A theme is markup, CSS, JS, images and declarations — never behavior. Templates cannot run queries, call services, register hooks, or execute arbitrary PHP. This is not a convention: a static analyzer (
php spark ironcms:theme:check) enforces it at install and activation time. Behavior belongs in modules; a theme + module bundle is the supported way to ship both. - The engine owns the brains. All data arrives in your templates as a prepared view-model. Escaping of rich content, SEO/meta output, the entire
<head>, URL building, and sanitization happen inside the engine — your template prints values, it does not compute or sanitize them. - Everything is declared, nothing is guessed. The engine reads
theme.jsonfor your templates, menu locations, content sections, customizer controls, data needs and compatibility requirements. It never infers anything from your markup.
A broken theme can never take the site down: if a template throws at render time, the engine logs it, alerts the administrator, and serves the built-in fallback views instead.
Quick start
The smallest valid theme is a folder under themes/ with a manifest and two files:
themes/my-theme/
├─ theme.json
└─ views/
├─ layout.php
└─ page.phptheme.json:
{
"name": "My Theme",
"version": "1.0.0",
"author": "You",
"requires": { "themeApi": "^1.0" },
"templates": ["page"]
}views/layout.php:
<!doctype html>
<html lang="<?= esc($locale ?? 'en') ?>" dir="<?= esc($localeDir ?? 'ltr') ?>">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<?= $loomHead ?>
</head>
<body>
<?= $loomBodyOpen ?? '' ?>
<main><?= $loomContent ?></main>
<?= $loomFooter ?? '' ?>
</body>
</html>views/page.php:
<article class="page">
<h1><?= esc($title) ?></h1>
<div class="content"><?= $content ?></div>
</article>Any template you do not provide falls back automatically — first to your parent theme (if you have one), then to the built-in views. You can theme one template at a time.
Run the checker while you work:
php spark ironcms:theme:check my-themePackage anatomy
The full tree a theme may ship:
themes/my-theme/
│
├─ theme.json ← identity + ALL declarations (§4)
├─ theme.sig ← (optional) vendor package signature (§18)
├─ screenshot.png ← admin theme-card image
│
├─ views/ ← view-only PHP templates (§5–§6)
│ ├─ layout.php ← the frame; the engine injects <head> content
│ ├─ home.php ← composed landing page
│ ├─ page.php ← generic page template
│ ├─ page-landing.php ← (optional) page-template variant (§4 pageTemplates)
│ ├─ password.php ← password-protected page gate
│ ├─ products/
│ │ ├─ index.php ← product catalog
│ │ └─ single.php ← product detail
│ ├─ parts/ ← fragments loaded with theme_part('name')
│ │ ├─ header.php
│ │ └─ footer.php
│ └─ modules/ ← module page SKIN overrides (§14)
│ └─ ironcms-blog/
│ ├─ index.php
│ └─ single.php
│
├─ sections/ ← content-section templates (§10)
│ ├─ hero.php
│ ├─ faq.php
│ └─ previews/hero.png ← (optional) gallery previews
│
├─ assets/ ← published to public/themes/my-theme (§13)
│ ├─ css/theme.css ← auto-linked when present
│ ├─ js/theme.js ← auto-linked (defer) when present
│ └─ img/ fonts/ …
│
├─ languages/ ← theme UI strings (§12)
│ ├─ en.json ← the reference locale
│ └─ tr.json
│
└─ demo/ ← sample-content package (§15)
├─ content.json
├─ theme-content.json
└─ media/…Deliberately absent: functions.php, hooks, config files, controllers, database access, PHP anywhere outside views/ and sections/. The checker rejects all of them.
Never written into the theme folder: published assets and caches live outside (public/themes/{slug}, the framework cache). Your theme directory stays a pure source.
theme.json reference
Everything except name is optional. Unknown extra keys are tolerated but ignored — do not rely on them.
{
"name": "My Theme", // REQUIRED — display name
"slug": "my-theme", // lowercase a-z 0-9 hyphen; defaults to the folder name
"version": "1.0.0", // semver-ish: "1", "1.2", "1.2.3" (+suffix)
"author": "You",
"description": "Short description shown on the theme card.",
"colors": ["#4263eb", "#22d3ee"], // card gradient when no screenshot.png ships
"parent": null, // parent theme slug — makes this a child theme (§16)
"requires": { // compatibility gate (§17)
"ironcms": ">=1.2.0", // core version constraint
"themeApi": "^1.0", // template/view-model contract version
"modules": { "ironcms/blog": "*" } // modules this theme skins (vendor/slug: constraint)
},
"templates": ["home", "page", "password",
"products/index", "products/single"], // templates this theme SHIPS
"pageTemplates": { // page-template variants; file = views/page-{key}.php
"landing": "Landing (full width)" // key "default" is reserved and rejected
},
"menuLocations": { // named menu slots the admin can assign menus to
"primary": "Primary menu",
"footer": "Footer menu"
},
"data": { // engine-resolved data requests (§8)
"recent_posts": 3, // int = limit (1–20), or true for the default
"site": true
},
"sections": [ // content sections (§10)
{
"id": "hero",
"label": "Hero",
"preview": "sections/previews/hero.png",
"fields": [
{ "key": "title", "type": "text", "label": "Title", "default": "Hello" },
{ "key": "body", "type": "rich", "label": "Body" },
{ "key": "image", "type": "image", "label": "Background" },
{ "key": "button", "type": "link", "label": "Call to action" }
]
},
{
"id": "faq",
"label": "FAQ",
"fields": [
{
"key": "items", "type": "repeater", "label": "Questions",
"default": [ { "q": "…", "a": "<p>…</p>" } ],
"fields": [
{ "key": "q", "type": "text", "label": "Question" },
{ "key": "a", "type": "rich", "label": "Answer" }
]
}
]
}
],
"customizer": [ // site-owner controls (§11)
{ "key": "accent", "type": "color", "label": "Accent color", "default": "#206bc4" },
{ "key": "radius", "type": "select", "label": "Corner radius",
"options": ["none", "md", "xl"], "default": "md" }
],
"slots": { // component placement points (§9)
"header_actions": [] // list of registered component names
},
"supports": ["sections"] // free-form capability flags
}Section field types: text, rich (HTML — always sanitized by the engine before your template sees it), image (a media-library path), link ({url, text} pair), number, toggle ('1'/'0'), select, and repeater (a repeatable group of sub-fields; sub-fields may use every type except another repeater — nesting depth is 1).
Customizer control types: color, select, text, number, toggle, image.
Keys (section ids, field keys, customizer keys, menu locations, page-template keys) match [a-z0-9_-]+. Template names may nest one directory deep (products/single).
Templates and the render pipeline
Template keys the engine resolves
| Key | Rendered for |
|---|---|
home | the composed landing page (when the site has no static front page) |
page | a regular page |
page-{key} | a page whose editor-selected template variant is {key} |
products/index | the product catalog |
products/single | a product detail page |
password | the password gate for a protected page |
modules/{vendor-slug}/{name} | a module page skin, e.g. modules/ironcms-blog/index (§14) |
search, 404 and products/category are reserved — no current route produces them; they will arrive with a minor theme-API version bump.
Resolution order
For each template key the engine looks through the chain — your theme, then its parent, then the parent's parent — and takes the first file it finds:
themes/{child}/views/{key}.php
themes/{parent}/views/{key}.php
(built-in fallback views)A theme only takes over when both the template file and a layout.php resolve somewhere in the chain. Parts (theme_part()), section templates, language files and assets resolve through the same chain.
The layout contract
Your layout.php is the page frame. It receives four engine-built strings and must print them verbatim:
| Variable | Print where | Contains |
|---|---|---|
$loomHead | inside <head> | favicons, <title>, robots/noindex, hreflang alternates, SEO/meta tags, the customizer CSS-variable block, analytics + custom head code, versioned links to every theme.css/theme.js in the chain |
$loomContent | where the page body goes | the rendered template output |
$loomBodyOpen | right after <body> | engine injections such as the tag-manager noscript frame (may be empty) |
$loomFooter | right before </body> | custom footer code + the cookie-consent bar (may be empty) |
Your layout never builds <head> content itself — no <title>, no meta description, no asset links. Fully static tags (<meta charset>, <meta viewport>) may live in the layout as plain HTML. The engine names are loom-prefixed so they can never collide with view-model keys like $content.
Failure behavior
If your template throws, the engine logs the error, records a warning card in the admin Action Center, audits the event, and re-renders the request with the built-in views and the original data. Visitors always get a page.
View-model reference
Templates are plain PHP files included in an isolated scope with the view-model extracted into local variables.
Common variables (every template)
| Variable | Type | Notes |
|---|---|---|
$siteName | string | always set |
$title | string | always set |
$metaTitle | string | may be empty — the engine falls back to $title in <head> |
$metaDesc | string | may be '' |
$metaKeywords | ?string | only on page / products/single |
$seoType | string | article / website / product |
$seoImage | ?string | may be '' |
$preview | bool | admin draft preview — read as $preview ?? false |
$previewNote | string | '' unless previewing |
$localeAlternates | array<string,string> | locale ⇒ absolute URL; [] on single-locale sites |
$localeXDefault | ?string | null on single-locale sites |
$locale | string | current request locale |
$localeDir | string | ltr or rtl |
$localeSwitcher | list<{code,label,url,active}> | [] on single-locale sites |
$homeUrl | string | site root URL |
$year | string | current year |
$socialLinks | list<{label,url}> | configured social profiles (http/https only) |
$privacyUrl | string | '' when no privacy page is configured |
$data | array | results of your theme.json data requests (§8) |
page / page-{key}
| Variable | Type | Notes |
|---|---|---|
$page | array | the page row, localized for the request (post_id, title, slug, status, visibility, template, noindex, featured_image, meta_*, published_at, …) |
$content | string | the page's rich HTML, already sanitized by the engine — print it raw: <?= $content ?> |
$featuredUrl | string | absolute URL of the featured image, or '' |
home
| Variable | Type | Notes |
|---|---|---|
$products | list<array> | up to 8 published products; each row carries slug, name, featured_image, price, sale_price, … plus engine-built url, image_url ('' when none) and price_html (ready-to-print price markup, '' when no price) |
$posts | list<array> | latest 3 published blog posts; each row plus engine-built url and image_url |
$currency | string | shop currency symbol |
$tagline | string | may be '' |
$shopUrl / $blogUrl | string | '' when the route does not exist |
products/index
| Variable | Type | Notes |
|---|---|---|
$products | list<array> | published products; same engine-built url / image_url / price_html per row as home |
$currency | string | |
$shopUrl | string |
products/single
| Variable | Type | Notes |
|---|---|---|
$product | array | product_id, name, slug, sku, price, sale_price (may be empty), excerpt, description (rich HTML — engine-sanitized, print raw), featured_image, og_image, meta_* |
$gallery | list<string> | media paths, may be empty |
$imageMedia | list<{path,alt,caption,is_cover}> | may be empty |
$galleryImages | list<{path,url}> | engine-built; derived from imageMedia or featured+gallery |
$baseImagesJson / $mediaRulesJson | string | ready JSON payloads for data-attributes — print with esc(…, 'attr') |
$mediaBase | string | absolute media/ base URL |
$mediaLayout | string | grid | slider | lightbox |
$priceFormatted / $salePriceFormatted | string | formatted prices, '' when absent |
$options | list<array> | option groups: group_id, name, help_text, display_type (select/buttons/image/swatch), values: list of {value_id, value, color, image, image_url} |
$specs | list<{key,value,type,value_text}> | value_text resolves booleans to localized Yes/No |
$documents | list<{path,title,url,label,ext}> | may be empty |
$mediaRules | list<array> | option-value → image rules |
$categories | list<array> | visible categories (name, …) |
$currency, $shopUrl | string | |
$jsonLd | string | a complete <script type="application/ld+json">…</script> — print raw |
password
| Variable | Type | Notes |
|---|---|---|
$slug | string | the protected page's slug |
$pwError | ?string | flash error, or null |
$unlockUrl | string | the unlock form action |
$csrfField | string | a complete hidden CSRF input — print raw inside your <form> |
The template API
These are the only functions a template may call. The static analyzer (§18) enforces this list exactly.
theme_part(string $name, array $vars = []): string
// Render views/parts/{name}.php through the chain. The part sees the running
// template's view-model with $vars overlaid. Unknown part -> ''.
theme_asset(string $path): string
// Versioned public URL for assets/{path}. The first theme in the chain that
// ships the file wins; the URL carries ?v={that theme's version}.
theme_setting(string $key, mixed $default = null): mixed
// Customizer value: saved site-owner value -> nearest manifest default in
// the chain -> $default. (§11)
theme_content(string $key, mixed $default = null): mixed
// Theme Content value with dotted access: 'hero' (whole section),
// 'hero.title' (one field), 'faq.items.0.q' (inside a repeater). (§10)
theme_lang(string $key, array $args = []): string
// Theme UI string: languages/{locale}.json -> en.json -> the key itself.
// {placeholder} tokens are replaced from $args. (§12)
render_menu(string $location, array $opts = []): string
// The menu assigned to a location as a <ul> (opts: {ulClass}). Prefer the
// locale-aware component: render_component('menu', ['location' => …]).
render_slider(string $slug): string
// A published banner/slider by slug; '' when missing or inactive.
render_component(string $name, array $args = []): string
// A named component from the registry (§9). Unknown name or a failing
// renderer -> ''. Built-ins: 'menu' {location, ulClass?}, 'slider' {slug}.
render_slot(string $slot): string
// Render the component list your theme.json `slots` declares for $slot,
// in order. Unknown slot/component -> ''.
render_sections(?string $section = null): string
// All visible content sections in theme.json order — or just one when
// $section is given. Hidden or unknown sections render ''. (§10)
esc(mixed $value, string $context = 'html'): string
// THE escape helper. Contexts: 'html' (default), 'attr', 'js', 'css', 'url'.Also allowed: control structures (if/else/elseif, foreach, ternary, null-coalesce), echo / <?=, casts, isset/empty, array literals, and variable reads.
Rejected — the checker fails your package on any of these: any other function call (including base_url, view, setting, lang, clean_html, json_encode, date, …), new, static calls (::), method calls (->m()), superglobals, variable variables, backticks, eval, include/require (parts load only through theme_part()), function/class declarations, global, exit, goto, throw, clone.
Escaping rules of thumb:
- Plain values you print →
esc($value); attribute values →
esc($value, 'attr').
- Rich HTML fields (
$content,$product['description'], sectionrich
fields) arrive already sanitized — print them raw. You could not call a sanitizer anyway.
- Engine-built HTML (
$loomHead,price_html,$jsonLd,$csrfField,
component output) — print raw.
Data providers
A theme cannot query, but it can request data in theme.json:
"data": { "recent_posts": 3, "categories": true, "menus": true, "site": true }The engine resolves the requests once per render and drops the results into the shared $data variable in every template. Requesting an unknown provider fails manifest validation — the whitelist is engine-controlled.
| Provider | Request | Row shape |
|---|---|---|
recent_posts | true (default 3) or a limit 1–20 | latest published blog posts, newest first; each row carries the post columns plus engine-built url and image_url ('' when no image) |
categories | true | visible product categories in tree order; each row carries a depth |
menus | true | {menu_id, name, location} — the registry, not markup; render with the menu component |
site | true | {name, tagline, locale, url} — localized site identity |
Every requested provider key is always present in $data (possibly as an empty list), so templates can rely on the key existing.
Menus, components and slots
Menu locations. Declare named locations in theme.json (menuLocations); the site owner assigns menus to them under Menus in the admin. Render one with the locale-aware built-in component:
<nav><?= render_component('menu', ['location' => 'primary']) ?></nav>Components are named renderers that modules register (e.g. a mini-cart). Your theme places them — with render_component() directly, or declaratively through slots:
"slots": { "header_actions": ["mini_cart"] }<div class="header-actions"><?= render_slot('header_actions') ?></div>Component output is the author's responsibility (already escaped); unknown components contribute nothing. In a child theme, the nearest manifest that declares a slot wins.
Note for component authors (module side): a component whose output is visitor-specific (cart contents, account state) must be designed to render a neutral placeholder and hydrate client-side — personal data must never end up inside cacheable page bodies.
Sections and Theme Content
Sections are theme-defined content blocks whose values the site owner edits under Appearance → Theme Content — the form is generated from your theme.json sections schema. Section templates live at the theme root (sections/{id}.php, not under views/) and resolve through the chain.
Render them where you want:
<?= render_sections() ?> <!-- every visible section, manifest order -->
<?= render_sections('hero') ?> <!-- exactly one section -->Inside sections/{id}.php you receive:
$fields— the resolved field values. Empty stored fields fall back to the
field's default from theme.json, so a fresh install renders complete. repeater fields are a list of row arrays. All rich values (flat or inside repeater rows) are already sanitized. Every image field also gains a {key}_url companion — the absolute media URL the engine builds for you ('' when the field is empty), since a view-only template cannot call base_url().
$sectionId— the section id.- …plus the running template's entire view-model.
Example:
<section class="hero">
<h1><?= esc($fields['title']) ?></h1>
<div><?= $fields['body'] ?></div>
<?php if ($fields['button']['url'] !== ''): ?>
<a class="btn" href="<?= esc($fields['button']['url'], 'attr') ?>"><?= esc($fields['button']['text']) ?></a>
<?php endif; ?>
</section>Owners can hide each section with a toggle; a hidden section renders '' even when requested by name — the owner's toggle always wins. Text and rich fields accept per-locale overrides in the same form; theme_content() and render_sections() return the localized values automatically.
The Section Builder (per-page compositions)
Declaring sections also lights up the Section Builder in the page editor: the site owner composes any page from your sections — add, drag to reorder, duplicate (the same section can appear multiple times with different values), hide per instance, and fill each instance's fields (with per-locale overrides for text/rich).
What this means for your templates:
- On
page/page-{key}templates,render_sections()renders the
page's composition — and only that. A page without a composition renders '' there, so adding the call to your page template never changes existing pages. Theme-global Theme Content values never bleed into pages; an empty instance field falls back to the theme.json field default.
- On every other template (
home, custom templates, parts), the behavior is
unchanged: manifest order + Theme Content values + the global show/hide.
- Your section templates are reused as-is — one
sections/{id}.phpserves
both the theme-global path and every Builder instance.
Give each section a preview image ("preview": "sections/previews/hero.png", raster formats, kept under ~500 KB) — it becomes the section's tile in the Builder gallery. A good pattern is a "canvas" page-template variant that renders nothing but render_sections(), so composed landing pages carry no page chrome (see the Default theme's page-canvas.php).
Customizer
Declare site-owner controls in theme.json (customizer); the admin generates the panel — you build no UI. Saved values are stored per site ("mods") and reach the front end in two ways:
- CSS variables. Every control with a saved value is emitted in the engine's
<head>block as--{key}on:root. Unset controls emit nothing — your stylesheet must carry the defaults:
``css :root { --accent: #206bc4; --radius: 8px; } /* theme defaults */ .btn { background: var(--accent); border-radius: var(--radius); } ``
This keeps a single source of truth for defaults and avoids any flash of unstyled content.
theme_setting()in templates, for values that affect markup rather than style: saved value → nearest manifestdefaultin the chain → your fallback argument.
Administrators can also live-preview a theme (with unsaved customizer drafts) through an admin-only tokenized URL — previews never affect visitors and require no work from the theme.
Translations
Theme UI strings live in languages/{locale}.json as one flat object per locale:
{ "read_more": "Read more", "footer_rights": "All rights reserved." }theme_lang('read_more')resolves: current locale →en→ the key itself.- Maps merge through the chain — a child theme overrides individual keys.
{placeholder}tokens are substituted from the second argument:
theme_lang('items_count', ['count' => 3]) with "items_count": "{count} items".
en.jsonis the reference set.ironcms:theme:checkwarns about keys
missing from (or extra in) other locales — ship them in sync.
These files are for the theme's own interface strings only. Site content is translated by the CMS itself.
Assets
Static files ship under assets/ and are published — copied to public/themes/{slug}/ — on install, activation, and via php spark ironcms:themes:publish. The theme folder itself is never served.
assets/css/theme.cssandassets/js/theme.jsare linked automatically in
$loomHead for every theme in the chain (parent first, so a child's files win), with ?v={version} cache-busting from each manifest. The JS loads with defer.
- Reference anything else with
theme_asset('img/pattern.svg')— the chain
is searched and the URL is version-stamped.
- Only static extensions are published: `js mjs css map json png jpg jpeg gif
webp svg ico avif woff woff2 ttf eot`. PHP or anything executable is never copied to the web root.
- SVG files are sanitized at publish time:
<script>elements,on*event
attributes and javascript: URLs are stripped.
- Bump
versionintheme.jsonwhenever assets change — that invalidates
visitors' caches.
Module skins
Modules with public pages (for example the Blog) render through the theme engine too. Resolution for a modules/{vendor-slug}/{name} key:
- Your skin:
views/modules/{vendor-slug}/{name}.php— e.g.views/modules/ironcms-blog/index.php. Rendered inside your layout. - The module's default skin, still inside your layout.
- The module's classic full-page view (no theming).
The skin's view-model is defined by the module (the Blog module documents $posts rows with url, dateText, image_url, pager links, and a sanitized contentHtml, etc.). Skin files are ordinary theme templates: the view-only rules and the checker apply unchanged, and rich values arrive pre-sanitized by the module.
If your skin depends on a module, declare it:
"requires": { "modules": { "ironcms/blog": "*" } }Only do that when the theme is unusable without the module — a declared module requirement blocks activation while the module is missing/disabled.
Demo content ("install sample content")
Ship a demo/ folder and the theme's admin card gains a Demo content button that seeds the site with your sample content:
demo/
├─ content.json ← pages / posts / menus / sliders / settings
├─ theme-content.json ← values for your theme.json sections
└─ media/ ← images (jpg/jpeg/png/gif/webp only)content.json:
{
"settings": { "site_tagline": "A fast, clean site." },
"pages": [
{ "slug": "about", "title": "About us",
"content": "<h2>Who we are</h2><p>…</p>",
"excerpt": "…", "featured_image": "demo-my-theme/about.jpg",
"template": "", "meta_description": "…" },
{ "slug": "home", "title": "Home", "template": "canvas",
"sections": [
{ "section": "hero", "hidden": false,
"values": { "title": "…", "body": "<p>…</p>",
"image": "demo-my-theme/hero.jpg",
"button": { "url": "/about", "text": "…" } } }
] }
],
"posts": [
{ "slug": "welcome", "title": "Welcome",
"content": "<p>…</p>", "excerpt": "…",
"featured_image": "demo-my-theme/post.jpg" }
],
"menus": [
{ "name": "Demo — Primary", "location": "primary",
"items": [ { "title": "Home", "url": "/" },
{ "title": "About", "page": "about" } ] }
],
"sliders": [
{ "slug": "home-hero", "name": "Home hero", "template": "hero",
"slides": [ { "title": "…", "subtitle": "…",
"image": "demo-my-theme/hero.jpg",
"link_url": "/about", "link_text": "Learn more" } ] }
]
}theme-content.json mirrors the Theme Content store:
{
"sections": { "hero": { "title": "…", "body": "<p>…</p>" } },
"hidden": [],
"i18n": { "tr": { "hero": { "title": "…" } } }
}Import rules (enforced by the engine — your package cannot bypass them):
- Seed-only, re-run safe. Existing content is never overwritten: an
existing page/post slug, menu name, or slider slug is skipped; a media file already in the library is not re-copied; a non-empty setting keeps its value; Theme Content imports only while the store for your theme is empty; a menu location is only assigned while unclaimed. Re-running fills gaps and reports everything skipped.
- Media files land under
uploads/demo-{slug}/…and are registered in the
media library — reference them in content.json as demo-{slug}/file.jpg. Only the image extensions listed above pass, and file contents are MIME-sniffed.
- All rich HTML passes the sanitizer at import time; titles and other plain
fields are tag-stripped; javascript:-style URLs are dropped.
- A page's optional
sectionskey seeds a Section Builder composition
(see §10.1): an ordered list of {"section", "hidden", "values"} instances validated against your sections schema — undeclared sections/fields never persist, rich values are sanitized at import time.
settingsmay only seed:site_tagline,meta_title_default,
meta_description_default, shop_currency, home_page (point the homepage at a demo page's slug — typically your composed home page).
- Blog
postsseed through the Blog module and are skipped gracefully
(reported, not an error) when the module is not enabled.
- Menu items are either
{"title", "url"}(custom link) or
{"title", "page": "<slug>"} referencing a page from the same package.
- Slider
templatemust be one of the banner templates (hero,slider,
grid, strip, sidebar, popup, countdown, logowall); anything else falls back to hero.
Child themes
Set "parent": "some-theme" and ship only what you change:
- Files (templates, parts, sections, assets, language files) override by
same path; everything else falls through to the parent.
- Manifests merge nearest-first per key: your customizer control, section
id, or slot declaration replaces the parent's; the rest are inherited.
- Requirements are checked across the whole chain — a child is only as
compatible as its parents.
- The admin can also generate a child theme from any parent's card
("Child theme"), producing a minimal manifest to start from.
Site owners should customize through a child theme so updates to the parent never overwrite their changes.
Compatibility: requires and the theme API version
The engine publishes a theme API version (currently 1.2.0) covering the view-model shapes (§6) and helper signatures (§7). Additive changes bump the minor version; breaking changes only ever land in a major.
Declare what you need:
"requires": { "ironcms": ">=1.2.0", "themeApi": "^1.0", "modules": { "ironcms/blog": "^1.0" } }Constraints support * (any), exact versions (1.2.0 or =1.2.0), comparisons (>=, <=, >, <) and ^ (same major, at least the given version). Activation is blocked with a clear reason while any requirement in the chain is unmet, and the theme card shows an Incompatible badge. Module constraints resolve against enabled modules — a disabled module counts as absent.
"themeApi": "^1.0" is the right declaration for any theme built against this guide.
The quality gate: ironcms:theme:check
php spark ironcms:theme:check # every installed theme
php spark ironcms:theme:check my-theme # one themeThe checker is the same code that gates uploads (always) and activation (hard everywhere except development mode, where it degrades to a warning so you can iterate in place). Errors block install/activation; warnings are advisory.
Errors:
theme.jsonmissing, unparsable, or violating the schema (§4);- any PHP file outside
views/orsections/; - any template using a function/construct outside the §7 allowlist;
- a declared template, page template, or section without its file (for a
child theme this degrades to a warning, since the file may resolve through the parent);
- an unparsable
languages/*.json.
Warnings:
- language files whose keys are out of sync with
en.json; - a
languages/folder without anen.jsonreference file.
Packaging, signing and distribution
Package format. Zip the theme folder — theme.json at the archive root or inside a single top-level directory:
my-theme.zip
└─ my-theme/
├─ theme.json
├─ views/…
└─ …Install pipeline. Admins install via Themes → Upload theme (a password re-confirmation guards it). Every upload passes, in order: archive hygiene limits (max 2 000 entries, 60 MB extracted, 200:1 compression ratio), extraction with path-traversal protection, manifest validation, the protected-slug guard, install-path confinement, and the full ironcms:theme:check gate — in every environment. Re-uploading the same slug updates the theme in place.
Slugs. Lowercase letters, digits and hyphens. The built-in theme slugs (default, aurora) are protected — an upload can never overwrite them.
Signing. First-party and vendor-approved packages ship a theme.sig signature; those install with a Verified badge. Unsigned themes install normally after passing the checker and are badged Unverified. A package that carries a signature which does not verify is rejected outright — never edit a signed package; rebuild and re-sign instead. (Signing is performed by the vendor at release; there is nothing a third-party theme must do.)
Deletion. The active theme, built-in themes, and any theme that still has child themes installed cannot be deleted.
CLI reference
| Command | Purpose |
|---|---|
php spark ironcms:theme:check [slug] | run the view-only/static gate (§18) |
php spark ironcms:themes:publish [slug] | publish theme assets to public/themes/ (refreshes discovery first) |
php spark ironcms:themes:refresh | re-scan themes/ (e.g. after copying a theme over FTP) |
Worked example: the Default theme
The shipped Default theme is the reference implementation of everything above. Its complete file list:
themes/default/
├─ theme.json
├─ views/
│ ├─ layout.php
│ ├─ home.php
│ ├─ page.php
│ ├─ page-canvas.php
│ ├─ password.php
│ ├─ products/index.php
│ ├─ products/single.php
│ ├─ parts/header.php
│ ├─ parts/footer.php
│ └─ modules/ironcms-blog/{index,single}.php
├─ sections/{hero,features,cta}.php
├─ sections/previews/{hero,features,cta}.png
├─ assets/css/theme.css
├─ assets/js/theme.js
├─ languages/{en,tr}.json
└─ demo/{content.json, media/…}Its manifest (sections abbreviated — see the shipped file for the full field lists):
{
"name": "IronCMS Default",
"version": "1.1.0",
"author": "IronCMS",
"description": "The default front-end theme — clean, fast and fully responsive.",
"colors": ["#4263eb", "#22d3ee"],
"requires": { "themeApi": "^1.0" },
"templates": ["home", "page", "password", "products/index", "products/single"],
"pageTemplates": { "canvas": "Canvas (sections only)" },
"menuLocations": { "primary": "Primary menu", "footer": "Footer menu" },
"sections": [
{ "id": "hero", "label": "Hero", "preview": "sections/previews/hero.png", "fields": [ "…" ] },
{ "id": "features", "label": "Features", "preview": "sections/previews/features.png", "fields": [ "…" ] },
{ "id": "cta", "label": "Call to action", "preview": "sections/previews/cta.png", "fields": [ "…" ] }
],
"supports": ["sections"],
"customizer": [
{ "key": "accent", "type": "color", "label": "Accent color", "default": "#206bc4" },
{ "key": "radius", "type": "select", "label": "Corner radius", "options": ["none", "md", "xl"], "default": "md" }
]
}How its pieces map to this guide:
- Layout — exactly the §2 skeleton plus a preview banner and two parts:
``php <?= theme_part('header') ?> <main><?= $loomContent ?></main> <?= theme_part('footer') ?> ``
- Header part — brand link (
$homeUrl,$siteName), the primary menu via
render_component('menu', ['location' => 'primary']), and the $localeSwitcher loop from §6.1.
- Footer part — the footer menu component,
$socialLinks,$privacyUrl
(labelled with theme_lang('privacy_policy')), and a copyright line from $year + $siteName + theme_lang('footer_rights').
- home.php — tries
render_slider('home-hero')first and falls back to a
static hero built from $siteName/$tagline; then a product grid and a post row straight off the §6.3 rows (url, image_url, price_html).
- page.php —
$featuredUrlimage,esc($title), raw$content(§6.2),
then render_sections() so Builder compositions (§10.1) render under the page body. page-canvas.php is the sections-only variant: optional $content, then render_sections() — no heading, no featured image.
- sections/{hero,features,cta}.php — the §10 contract end to end:
esc() on text, raw pre-sanitized rich, {key}_url for the hero image, a repeater loop (features), select/number/toggle fields driving classes.
- password.php — the §6.6 form:
$unlockUrlaction, raw$csrfField,
theme_lang('pw_prompt'/'pw_placeholder'/'pw_submit').
- products/index.php + products/single.php — the §6.4/§6.5 view-models;
the gallery uses $baseImagesJson/$mediaRulesJson printed with esc(…, 'attr') into data-attributes, and assets/js/theme.js reads them.
- Styling —
assets/css/theme.cssdefines:root { --accent: …; }
defaults and uses var(--accent) throughout, so the customizer's saved values (§11) restyle it without any template logic.
- Languages —
en.json/tr.jsoncarry the keys used above
(footer_rights, privacy_policy, home_*, read_more, no_products, product_*, pw_*, blog_*), in sync.
- Demo — a composed
homepage (hero + features + cta on thecanvas
variant, with home_page seeded to it), pages (about, start-here), one blog post, primary/footer menus, a home-hero slider and three images under demo/media/ (§15).
Rebuild those files against the contracts in §5–§13 and you have rebuilt the Default theme.