Docs: Themes
Themes
How a Tilspire theme is structured, what core decides for it, how to fork the starter theme, and why you should never edit it in place.
A Tilspire theme is a plain folder of templates, components and assets — nothing compiled, nothing built.
Anatomy of a theme #
- theme.json — the manifest:
name,version,author,description,licenseandtags, plus an optionaloptionslist whose entries (key,label,type,defaultand a few more) become settings you can change in the admin panel. - components/ — shared partials, such as the header and footer.
- views/ — the templates for each kind of page Tilspire renders.
- assets/ — the theme's own CSS, JavaScript, fonts and images. An optional
assets/editor.cssstyles the text in the Pages and Posts editors, per layout and category. Start every rule with.tsp-editor. The Profile page offers the Immersive editor switch only while the active theme ships this file.
A theme that draws its own sign-up form (views/auth-register.php) calls <?php $this->signupChecks(); ?> inside the form, before the submit button, since 1.17.3. It adds the checks that keep bots out. Without it, sign-ups are held to the per-address limit alone, and Health says so.
Raise the theme's version in theme.json whenever you ship a change. Since 1.19.0, installing or updating a theme in the admin panel clears the page cache, and a theme copied onto the server another way (Git or an upload) clears it on the first visit after its version changes. Change the files without raising the version and visitors keep the old pages until they expire.
What a theme provides, and what Tilspire fills in #
Since 1.4.0, what a theme owes the modules it displays is written down. A theme claims each job it wants to do itself; for every job it doesn't claim, Tilspire fills in a working default, so a module always renders properly on any theme.
| The job | If the theme doesn't claim it |
|---|---|
| A content container: the width and padding around page content | Tilspire adds a small stylesheet that constrains it |
| The icon set modules use | Tilspire loads the icons when a page needs them and nothing else has |
| The stylesheets and scripts a module or page asks for | Tilspire adds them to the page itself |
| The SEO head block: title, description, canonical link, robots, Open Graph, Twitter and JSON-LD | Tilspire writes the parts the theme left out, and leaves the ones it wrote alone |
A way in: a link to /account for members | Nothing can be filled in here — put the link in your navigation |
The --cms-* colours, radii and fonts modules style themselves with | Modules fall back to neutral values of their own |
| A language switcher, only while the site has an extra content language | Tilspire adds a plain one before the end of the page |
The page's language: <html lang> on a translated page | Tilspire corrects a missing, empty or default-language value |
| The design tokens, for a theme whose options declare CSS: the colours, fonts and sizes chosen under Site ▸ Design | Tilspire adds the block just before the end of <head> |
A cookie banner, since 1.18.0 and only while cookie consent is on: consentBanner() | Tilspire adds its own banner right after <body>, in your theme's consent_style option |
A "Cookie settings" link, under the same condition: consentLink() | Tilspire adds a plain button before the end of the page |
| A page's settings parts, since 1.19.0 and only while their switch in Pages ▸ Settings is on: the trail, "Last updated" and "In this section" | Tilspire draws the trail first in <main> and the other two just before the footer, each in a plain page container. Calling pageTrail(), pageUpdated() or pageChildren(), or placing the part with component(), claims it |
| A notification bell, since 1.20.0: core's notification-bell component | Tilspire draws the bell beside the account menu. A theme with its own bell keeps it. A theme forked before 1.20.0 shows it only where it places the component and core's notifications.css, and members still reach their notifications from the account page |
A page's Share row, since 1.21.0 and only while the Share switch in Pages ▸ Settings and the page's own Share switch are both on: pageShare() or the page-share component | Tilspire draws the row at the end of the page, just before the footer |
The site's addition to the privacy policy, since 1.21.0, on the page named by the privacy page setting (today it holds the online status text): pagePolicy() or the page-policy component | Tilspire draws it last in <main>, before the footer |
A theme that claims a job gets its page back untouched, and keeps control over where things go.
Content fields in your templates #
Pages built on a content-model template carry typed fields. Themes read them through the Template API — field(), rows() and related() — which escapes each value according to its declared type. The starter theme shows how, and the Template API lists every call: pages by Layout or parent, dates, pictures, links, the logo and more.
Design #
Since 1.15.0, Site ▸ Design changes the active theme's colours, fonts, sizes and layouts without editing a file. A theme declares what may change in its theme.json options: a colour, number or font option can name the CSS custom property it sets, and a layout option offers the layouts the theme itself provides. Tilspire writes only those values, from allowlists, and fonts come from a set it hosts itself, so nothing is fetched from elsewhere.
A change is proposed, never applied at once: it waits in the Review queue, where you can preview it on your site as it looks now and after. A colour pair that fails the WCAG contrast check is refused, with its ratio. The Assistant and the Operator API can propose designs the same way.
Languages and menus #
On a site with more than one language, the Template API returns the visitor's language, and menus reach a theme through menu() already translated. A theme that shows no language switcher gets a plain one from Tilspire.
A theme draws, core decides #
Since 1.18.0 a theme decides how things look, never who may do what. Everything it is given arrives decided: lists already filtered for the visitor, finished addresses, and a control as one call.
- Named actions. Buttons such as Reply, Quote and Delete come from
action()andactions(), which print the finished control, or nothing when this visitor isn't offered it.may()answers yes or no for the same control. A theme no longer tests roles or permissions to show or hide one. - Maintenance. With maintenance mode on, Tilspire answers visitors with its own maintenance page before any template runs, so a theme needs no maintenance code. Staff still see the site;
site()['maintenance']is true while it is on, for a banner. - Section addresses.
section('blog')orsection('forums', '/t/1-hello')returns a section's address as the site named it, so a link follows a renamed section instead of going through a redirect. Write that, never/blogor/forums. - The site's address.
site()['url']follows the address inconfig.phpfirst, as Tilspire's own links do, and the setting only where that is unset.
Custom themes keep working. The theme-author guide in site/themes/README.md lists what to change, and why. The same checklists are on this site: Upgrading from 1.16, Upgrading from 1.17, Upgrading from 1.18, Upgrading from 1.19 and Upgrading from 1.20.
Small overrides, not copies #
Prefer a small override to a copied view. Since 1.19.0 a module view draws its heading through the page-head component: ship components/page-head.php to restyle some headings and call pageHeadDefault() for the rest. A view may also offer a slot (the Blog post has blog.post.after_head and blog.post.after_body), filled by components/slots/<name>.php. Small components such as blog-card, pager and person-avatar can be replaced the same way. A copied view freezes and misses every later change.
Member profiles #
Core draws member profiles (/members/<id>-<name>), the Edit profile page and the account page. A theme may override member-profile, member-missing, account-profile and auth-account; core's views are the floor. member-missing must print nothing that depends on the request. Define --cms-profile-band to colour the band of a profile without a banner.
New in 1.21.0 #
All of this is additive. Both shipped themes already carry it, and Upgrading from 1.20 lists what a forked theme must do. STABILITY.md lists these parts as Settling: they may still change in a 1.x release.
- Share. Core's
sharecomponent draws the share row. It takes its colour from--cms-accent, with a blue fallback. The Blog's share script,blog-share.js, is gone and now answers 404, so remove any line that loads it. The Blog'sblog-sharecomponent and the newblog-discussioncomponent (the link to a post's forum topic) are described on Posts. - Online status.
viewerSeesPresence()says whether this reader sees it. Theperson-avatarcomponent takes apresence_idand draws the dot, which--cms-onlinecolours. Themember-profileview prints the presence line. Forums add a side column (.forums-body > .forums-mainbesideaside.forums-side) and.forums-bottomfor the widget cards. - Direct messages. The
message-envelopecomponent sits beside the bell.messageButton($userId)draws a Message button.visitor()gains themessages_*keys. - Restrictions.
restrictionNotice()tells a restricted member what applies. A customcomments-formview must draw$restriction.auth-accountreceives$restrictions, whosewhereandreasonarrive already escaped with<bdi>, and its section carries the idrestrictions. - Community rules.
rules(),rulesLink($spot)andrulesAccept()draw the rules, the links to them and the accept card. An optionalviews/rules.phpdraws the rules page. While the rules are on,rulesis a reserved address. - Pictures. Forum posts and comments carry
images. Thepicturesandpictures-fieldcomponents draw them and the upload field, and the comment form gainsform.images. - Badges.
member-profilegainsawards, and theforums-awardscomponent draws a member's badges. The badge tooltip takes--fx-award-tip-radius,--fx-award-tip-bgand--fx-award-tip-ink. - Dates. The full date of a
timeTag()now goes todata-tooltip, nevertitle. A newclockstyle reads recent dates as "yesterday, 15:14". - Signature. The slot
account-profile-extraon the Edit profile page holds the signature field.
Theme preview #
Since 1.18.0, staff with the preview_themes permission can browse the live site in a theme that isn't published yet, page after page. (manage_themes allows it too.) Start it from Site ▸ Themes.
- The preview exists in that person's own browser session only. Visitors keep seeing the live theme.
- A previewed page is never cached, so it can't be served to anyone else.
- A strip at the top of every page names the theme, says that visitors see the live theme, and has a Stop button. With
manage_themesit also has Copy options, which copies the live theme's saved option values into the previewed theme (it asks first). With View as, a role choice looks at the site as a role or a guest. If the page has a form, the strip warns that what you submit is written to the live site. - The admin panel always uses the live theme. Making the previewed theme live ends the preview.
theme-previewis a reserved address: no page can use it as its address.
Choosing the active theme #
Set the active theme under Site ▸ Themes. It applies across the whole site.
Start from the starter theme #
Tilspire ships with a starter theme at site/themes/default/. It's built to the theme contract and written to be read end to end and forked, not treated as a finished showcase. Copy it into a new folder under site/themes/, rename it in its theme.json, and activate your copy.
A theme forked before 1.14.0 #
If your theme asks can('access_admin') to decide who is staff, for example to let staff past the maintenance page, a staff member browsing the site is treated as a visitor: since 1.14.0 staff can sign in on the site, and access_admin is only true while they are signed in to the admin panel. On 1.18.0 the fix is to remove the test: Tilspire handles maintenance itself, and controls come from action() (above).
Never edit the starter theme in place #
site/themes/default/ is one of the paths Tilspire's updater manages. Every update overwrites it completely, so any change you make there directly is lost the next time you update. Always work in a copy.