Documentation

Views, themes, languages

Everything you change about how the panel looks or speaks lives in your application. Updating the module replaces its folder and keeps your changes.

Replacing a view

Every view of the panel and every email template goes through CodeIgniter's view overrides. Copy the module's file to the same path under app/Views/overrides/RoleWarden/ and edit the copy:

Module fileYour copy
src/Views/roles/show.phpapp/Views/overrides/RoleWarden/Views/roles/show.php
src/Views/layouts/panel.phpapp/Views/overrides/RoleWarden/Views/layouts/panel.php
src/Views/emails/new_sign_in.phpapp/Views/overrides/RoleWarden/Views/emails/new_sign_in.php
src/Views/auth/login.phpapp/Views/overrides/RoleWarden/Views/auth/login.php

Keep the copy in step when you update: a new version may pass new variables to a view or need new markup. The CHANGELOG.md says when a view changes. Escape every value you print with esc(), and keep csrf_field() in every form.

Shield's other screens (registration, password recovery) stay Shield's; restyle them with Shield's own $views setting.

Themes

Three themes ship with the panel: Console (dense, the default), Clarity (airy) and Contrast (high contrast), each in light and dark. Every signed-in user picks light, dark or "System" from the top bar.

The theme for everyone

/rolewarden/appearance (permission appearance.update) sets the starting theme, background, text and accent colours for light and dark, corner radius and density, with a live preview and a warning on any text colour below WCAG AA. The result is saved in writable/rolewarden/theme.json, a file of your application, so the folder must be writable by the web server.

A theme under version control

Download the theme from the Appearance screen and save it as app/Config/RoleWarden/theme.json. When that file exists it wins over the one in writable/, and the panel shows it without letting anyone change it.

A theme of your own

Declare it in your config class and write its tokens in a stylesheet of your application:

// app/Config/RoleWarden.php
public array $extraThemes = ['ocean' => 'Ocean'];
public ?string $themeStylesheet = '/css/rolewarden-theme.css';
/* public/css/rolewarden-theme.css */
:root[data-rw-theme="ocean"] {
  --l-accent: #0b6e8a;
  --d-accent: #5cc3dd;
  /* ...every --l-* and --d-* token, as the design guide lists them */
}

The design guide lists every token with its value in each theme, and how a fourth theme is built.

Languages

The panel and the security emails come in English and Italian. Each user picks the language from the top bar of any page or from their profile; until they do, the panel follows the application's locale (Config\App::$defaultLocale, or the negotiated one when $negotiateLocale is on).

One language only

List the languages to offer in app/Config/RoleWarden.php. With a single one the language switch disappears from the top bar and from the profile, and every page and email is in that language, whatever the application's locale:

<?php

namespace Config;

class RoleWarden extends \RoleWarden\Config\RoleWarden
{
    public array $languages = ['en'];
}

Another language

Copy the module's src/Language/en/RoleWarden.php to app/Language/{locale}/RoleWarden.php, for example app/Language/fr/RoleWarden.php, and translate the values; RoleWardenData.php next to it holds the names of the seeded roles and permissions. It appears in the top bar and in the profile's list at once, named in its own language. Lines you leave out fall back to English. Keep the placeholders ({0}, %s, {0, plural, ...}) as they are.

Role and permission names

The roles and permissions the module seeds are stored in English and shown in each reader's language, from Language/{locale}/RoleWardenData.php. Once an admin changes a name or a description, it is shown as written, in every language. To translate your own roles and permissions the same way, put their stored English text in app/Language/en/RoleWardenData.php and the translation in app/Language/{locale}/RoleWardenData.php, under roles.{slug}.name, roles.{slug}.description and permissions.{area}.{action}. Area names (the headings of the Permissions screen and the rows of the matrix) go under areas.{area}; an area without one shows its slug with a capital letter. Action names (the columns of the matrix) go under actions.{action}; an action without one shows its slug.

Changing a few lines

Put only those lines in app/Language/{locale}/RoleWarden.php, nested as in the module's file: CodeIgniter merges them over the module's.

<?php

return [
    'panel' => [
        'nav' => [
            'users' => 'People',
        ],
    ],
];

CodeIgniter's own messages

Validation errors and relative dates come from CodeIgniter itself. Their translations are in the official codeigniter4/translations package, already included in the complete application: composer require codeigniter4/translations elsewhere. Shield ships its own.