Skip to content

Theme ​

Chevereto ships with the Peafowl theme, a PHP theme located at content/legacy/themes/Peafowl/. You can customize it at different levels, from dashboard settings to a full theme clone, without editing the core files.

MethodUse it forSurvives upgrades
Dashboard settingsPalette, font, custom CSS and JSYes
Custom hooksAdd code at fixed spots in every pageYes
Theme overridesReplace any theme file with your own versionYes
Clone themeBuild your own theme from PeafowlYes, but no fixes

Theme structure ​

PathContents
views/Page views, one per route (image.php, user.php, ...)
snippets/Partials used by views (forms, modals, listings, inline JS)
tpl_list_item/Templates for items in listings (images, albums)
mails/Email templates
head.phpThe <head> of every page
header.phpLoads head.php and opens <body>
footer.phpCloses the page and loads the JavaScript
functions.phpTheme functions, loaded before the view
style.cssTheme styles (style.min.css is the file loaded)
lib/Peafowl CSS, Chevereto JS bundle, Font Awesome
custom_hooks/Custom hooks
overrides/Theme overrides

Dashboard settings ​

/dashboard/settings/theme

Before touching any file, check what can be done from the dashboard:

  • Theme: The active theme, any folder in content/legacy/themes/.
  • Default palette: The color scheme. Users can also pick their own if Enable user palette selection is on.
  • Default font: The font family.
  • Custom CSS code: Added as a <style> tag inside <head>.
  • Custom JS code: Added as a <script> tag inside <head>.

Settings are stored in the database, so they are kept across upgrades and Docker rebuilds.

Palettes ​

The <html> element gets the palette-<name> class and a data-palette attribute for the active palette. The available palettes are system, blanco (Light), dark, flickr, imgur, deviantart, lush, graffiti, abstract, cheers and cmyk.

Colors are defined as CSS variables. The light palette defines them on :root and the other palettes redefine them with .palette-<name>:root (see snippets/theme_colors.css.php). To change the accent color of the light palette:

css
:root {
    --colorAccent: #e91e63;
    --colorAccentStrong: #c2185b;
}

To change a specific palette, use its selector:

css
.palette-dark:root {
    --linkText: #ff80ab;
    --buttonAccentBackground: #e91e63;
}

Add this CSS in Custom CSS code or in the style.css hook.

Custom hooks ​

content/legacy/themes/Peafowl/custom_hooks/

Custom hooks let you add code at fixed spots of the theme. Chevereto loads a hook when its file exists, and skips it otherwise.

Each hook ships as a .sample file. To enable a hook, copy the sample removing .sample from its name and edit the copy. For example, copy head.sample.php to head.php.

FileWhere it goes
head_open.phpRight after <head>
head.phpRight before </head>, after all the theme styles
head_after.phpRight after </head>
header.phpAfter head_after.php, before <body>. Useful for PHP logic
body_open.phpRight after <body>
footer.phpIn the footer, before the Chevereto JavaScript is loaded
share_links.phpDefines the share buttons
style.cssLinked as a stylesheet after the theme styles and Custom CSS

The body_open.php hook also runs on the pages that don't use the theme header, like login, signup and account pages.

For example, to add a verification meta tag create custom_hooks/head.php:

php
<?php

// @phpstan-ignore-next-line
if (!defined('ACCESS') || !ACCESS) {
    die('This file cannot be directly accessed.');
}
?>
<meta name="example-site-verification" content="your-token">

Hooks run in the theme context, so you can use the same functions and variables available in the views, like Handler::var() and getSetting().

Direct access guard

Keep the ACCESS check at the top of your PHP hooks. It prevents the file from running if it's requested directly by URL.

Errors are silenced

Errors in PHP hooks are caught and ignored, so a broken hook won't break your website, but it won't show anything either. If a hook doesn't work, check it for syntax errors with php -l.

The share_links.php hook replaces the list of share buttons. Copy share_links.sample.php to share_links.php and edit the $share_links_networks array:

php
<?php

global $share_links_networks;
$share_links_networks = [
    'mail' => [
        'url' => 'mailto:?subject=%TITLE%&body=%URL%',
        'label' => 'Email',
    ],
    'bluesky' => [
        'url' => 'https://bsky.app/intent/compose?text=%TITLE%%20%URL%',
        'label' => 'Bluesky',
    ],
    'whatsapp' => [
        'url' => 'whatsapp://send?text=%TITLE%%20%URL%',
        'label' => 'WhatsApp',
        'mobileonly' => true,
    ],
];
KeyDescription
array keyNetwork name, also used as the Font Awesome brand icon (fa-<key>)
urlShare URL, with placeholders
labelButton tooltip
iconOptional icon name, if it differs from the key
mobileonlyOptional, show the button only on phones

Placeholders are replaced with the URL-encoded values of the shared content: %URL%, %TITLE%, %DESCRIPTION%, %IMAGE%, %HTML% and %TWITTER% (the X account in settings).

The list you define replaces the default one entirely, so include every network you want to show. Share buttons only show when Enable social share is on in the theme settings.

Theme overrides ​

content/legacy/themes/Peafowl/overrides/

Theme overrides replace a theme file with your own version. Chevereto checks the overrides/ folder first and uses your file instead of the original one.

Overrides follow the same structure as the theme. To override a file, copy it to the same relative path inside overrides/ and edit the copy:

Original fileOverride file
views/image.phpoverrides/views/image.php
snippets/modal_share.phpoverrides/snippets/modal_share.php
tpl_list_item/image.phpoverrides/tpl_list_item/image.php
mails/account-welcome.phpoverrides/mails/account-welcome.php
header.phpoverrides/header.php
functions.phpoverrides/functions.php
style.min.cssoverrides/style.min.css
lib/peafowl.min.cssoverrides/lib/peafowl.min.css
lib/chevereto-all.min.jsoverrides/lib/chevereto-all.min.js

For example, to customize the image page copy views/image.php to overrides/views/image.php and edit it. Chevereto now uses your file to render the image page. To restore the default, delete the override.

Overrides also work for files that don't exist in the theme. A custom route named hello renders overrides/views/hello.php.

Overriding hooks

PHP hooks can also be placed at overrides/custom_hooks/, so you can keep all your changes in the overrides/ folder. The exception is style.css, which must be at custom_hooks/style.css.

Built files

The browser loads the minified style.min.css, lib/peafowl.min.css and lib/chevereto-all.min.js. Overriding the source files (style.css, lib/js/chevereto.js) has no effect, override the minified file instead.

Clone theme ​

If you need deeper changes you can clone Peafowl into a new theme:

  1. Copy content/legacy/themes/Peafowl/ to content/legacy/themes/MyTheme/. The folder name can only contain letters, numbers, -, _ and ..
  2. Go to /dashboard/settings/theme and select MyTheme in Theme.

If the configured theme folder doesn't exist, Chevereto falls back to Peafowl.

The lib/ assets (Peafowl CSS, Chevereto JS and Font Awesome) are always loaded from Peafowl/lib/, even when using a cloned theme. To change them, use overrides/lib/ in your theme.

Clones don't get updates

When you upgrade Chevereto only Peafowl gets updated. A cloned theme keeps the old views, which may not work with the new version. Prefer overrides for most customizations and clone only when you need to change most of the theme.

Upgrades ​

Upgrading Chevereto replaces the files that ship with it and keeps the rest. Your custom hooks, overrides and cloned themes are kept, but the original files you copied from may change.

To keep track of these changes, create a git repository with the Chevereto files and commit each new version. Use git diff between versions to see what changed in the files you have overridden, and merge those changes into your copies.

Docker ​

In Docker the application lives at /var/www/html and the files are replaced when you rebuild the image. Mount your customizations so they survive rebuilds:

yaml
volumes:
  - ./theme-overrides:/var/www/html/content/legacy/themes/Peafowl/overrides
  - ./style.css:/var/www/html/content/legacy/themes/Peafowl/custom_hooks/style.css

Place your PHP hooks at ./theme-overrides/custom_hooks/ to load them from the overrides mount.

Released under the Apache-2.0 License.