Docs: Template API
The Template API
Every call a tilspire theme can make, in seven parts. Start here: how each call returns its text, and what it does when nothing is found.
Everything a theme's view may ask of tilspire is a method on $this. You read content, the site and the request through these calls, never through SQL, page_data, $_SESSION or $_GET. A query of your own forgets drafts and translations, and bypasses the page cache's rules.
How text comes back #
- E, escaped. Echo it as it is. Never pass it through
htmlspecialchars()again. - P, plain. Escape it as you print it:
htmlspecialchars($v, ENT_QUOTES, 'UTF-8'). - M, markup. Core cleaned it when it was saved, or built it. Echo it as it is.
Nothing throws on a public page. A list that cannot be built is empty, and a lookup that finds nothing is null or an empty string. A shape may gain keys in 1.x. A key is never removed or given another type.
2
Fields and pictures
The page being shown: field, fieldRaw, hasField, boundFields, rows, related, pictures, picture, image and link.
3
Other pages and menus
Reaching beyond the current page: page, children, siblings, pages, breadcrumbs and menu.
4
Posts
The Blog's posts in a theme: posts and post.
5
The site, the visitor and the request
The site, the visitor and the request: site, visitor, hasModule, query, currentUrl, lang, languages and langUrl.
6
Head, assets and views
Dates, the head and the files around a view: date, seo, assets, asset, providesContainer, option and render.
7
Search, comments and previews
Site search, comments and drafts: searchResults, comments and isPreview.
8
Upgrading from 1.16
Five habits from 1.16 themes worth replacing, and the call to use instead of each.