What do the variables in theme arrays represent in SS4?

Silverstripe 4.11.2

In SilverStripe\View\SSViewer themes and SilverStripe\LoginForms\EnablerExtension login_themes are variables like $default - does this represent ‘app/templates’?

In SilverStripe\LoginForms\EnablerExtension there’s also $public - what does this refer to? Are there other vars that can be used in these lists?

And are they traversed starting from the top when SS is searching for a template?

Looking at the source code, there are only those identifiers:

/**
 * Identifier for the default theme
 */
const DEFAULT_THEME = '$default';

/**
 * Identifier for the public theme
 */
const PUBLIC_THEME = '$public';

$default is a pseudo-theme representing all modules (silverstripe/framework included) with a templates folder, while $public is the public webroot. You can shuffle them to get the precendence you need, i.e. I often use this sequence:

SilverStripe\View\SSViewer:
  themes:
    - '$public'
    - '/app'
    - 'mytheme'
    - '$default'

to be able to override any template within my app folder and having mytheme overriding any default template, if needed.

$public is not used by templates, but since Silverstripe 4.1.0 it allows <% require themedCSS('style.css') %> to find a file committed to public/css/style.css.

---
Name: mytheme
---
SilverStripe\View\SSViewer:
  themes:
    - '$public'
    - 'simple'
    - '$default'

$public theme set#

In addition there is a new helper pseudo-theme that you can configure to expose files in the public/ folder to the themed css / javascript file lookup. For instance, this is how you can prioritise those files:

This would allow <% require themedCSS('style.css') %> to find a file committed to public/css/style.css.

Note that Requirements calls will look in both the public folder (first) and then the base path when resolving css or javascript files. Any files that aren’t in the public folder must be exposed using the composer.json “expose” mechanism described below.

$default theme set#

$themeset - Any $ prefixed name will refer to a set of themes. By default only $default set is configured, which represents all module roots with a templates directory.

To define extra themes simply add extra entries to the SilverStripe\View\SSViewer.themes configuration array. You will probably always want to ensure that you include ‘$default’ in your list of themes to ensure that the base templates are used when required.