index

Theming

How themes are structured is still actively fluctuating. Please bear that in mind! No backwards compatibility is offered currently.

Coral themes are only composed of a few files and directories, all residing within theme_dir:

Path Function
error.html Error message template
page.html Page template
sitemap.html Sitemap template
static/ Directory containing static files

The fastest way to get acquainted with how themes work is to read the next section and then explore the reference theme.

Template format

Templates are written in plain HTML, extended by the templating system of Fat-Free-Framework (F3). Templates are quite simple and intuitive. For example, the following code inside page.html sets the page title:

<title>{{ @page.title }} &bull; {{ @config.site_name }}</title>

Each template gets its own set of variables set by the controllers.

Variables

In page.html:

Name Contains
@page An object with propreties title, file_path, markdown, html, updated_at (unix timestamp), updated_by
@config An object containing the Coral configuration (as written in config.php)

In error.html:

Name Contains
@ERROR The error object given by F3
@config An object containing the Coral configuration (as written in config.php)

In sitemap.html:

Name Contains
@current_dir The directory the user is inside (string)
@sitemap_dirs List of directories (string)
@sitemap_files List of files, as an object with a url and title
@config An object containing the Coral configuration (as written in config.php)

Template functions

Templates can also use all theme_* helper functions.

Signature Action
theme_asset_url(string $url) Converts the name of a static file into a full path to it
format_unix_time(int $time) Formats a unix time
format_unix_time_diff(int $time) Format a unix time as a difference between now and that time (x days ago, ...)