Theme class represents the CMS theme CMS theme is a directory that contains all CMS objects - pages, layouts, partials and asset files.. The theme parameters are specified in the theme.ini file in the theme root directory.

  • October\Contracts\Twig\CallsMethods

Protected Properties

protected string $dirName

dirName specifies the theme directory name

protected static mixed $activeThemeCache

activeThemeCache in memory

protected static mixed $editThemeCache

editThemeCache in memory

protected mixed $configCache

configCache keeps the cached configuration file values

Public Methods

public __get()

public __get($name): void

__get magic

public __isset()

public __isset($key): void

__isset magic

public static all()

public static all(): array 

all returns all themes on disk

public static allAvailable()

public static allAvailable(): array 

allAvailable returns all available themes, those that are not locked

public databaseLayerEnabled()

public databaseLayerEnabled(): bool 

databaseLayerEnabled checks global and local config

public static exists()

public static exists($dirName): bool 

exists determines if a theme with given directory name exists

public static getActiveTheme()

public static getActiveTheme(): Cms\Classes\Theme|null 

getActiveTheme returns the active theme object

public static getActiveThemeCode()

public static getActiveThemeCode(): string|null 

getActiveThemeCode returns the active theme code.

By default the active theme is loaded from the cms.active_theme config item. If there's a back-end user session, loads the theme code from the CMS Editor Edit Theme user preference.

This behavior can be overridden by the cms.theme.getActiveTheme event listener.

public getCachedThemePath()

public getCachedThemePath(): string 

public getConfig()

public getConfig(): array 

getConfig reads the theme.yaml file and returns the theme configuration values

public getConfigArray()

public getConfigArray($name): array 

getConfigArray returns an array value from the theme configuration file by its name

If the value is a string, it is treated as a YAML file and loaded.

public getConfigValue()

public getConfigValue($name, $default = null): void

getConfigValue returns a value from the theme configuration file by its name

public getCustomData()

public getCustomData(): Cms\Models\ThemeData 

getCustomData returns data specific to this theme

public getDatasource()

public getDatasource(): October\Rain\Halcyon\Datasource\DatasourceInterface 

getDatasource returns the theme's datasource

public getDirName()

public getDirName(): string 

getDirName returns the theme directory name

public static getEditTheme()

public static getEditTheme(): Cms\Classes\Theme|null 

getEditTheme returns the edit theme

public static getEditThemeCode()

public static getEditThemeCode(): string|null 

getEditThemeCode returns the edit theme code

There are several ways the edit theme can be set. The code loads the edit theme from the following sources: → CMS Editor edit theme for the currently authenticated back-end user, if any. → cms.edit_theme config item. → CMS Active theme. → cms.theme.getEditTheme event. The theme code returned by the event handler has the highest priority.

public getFormConfig()

public getFormConfig(): array 

getFormConfig returns the dedicated form option that provide form fields for customization, this is an immutable accessor for that and also an solid anchor point for extension

public getId()

public getId(): string 

getId is a helper for {{ }} twig vars that returns a unique string for this theme

public getParentOptions()

public getParentOptions(): array 

getParentOptions returns dropdown options for a parent theme

public getParentTheme()

public getParentTheme(): Cms\Classes\Theme|null 

getParentTheme returns a parent theme, if enabled

public getPath()

public getPath($dirName = null): string 

getPath returns the absolute theme path.

public getPreviewImageUrl()

public getPreviewImageUrl(): string 

getPreviewImageUrl returns the theme preview image URL

If the image file doesn't exist returns the placeholder image URL.

public getTwigMethodNames()

public getTwigMethodNames(): array 

getTwigMethodNames returns a list of method names that can be called from Twig.

public hasCustomData()

public hasCustomData(): bool 

hasCustomData returns true if this theme has form fields that supply customization data

public hasParentTheme()

public hasParentTheme(): bool 

hasParentTheme checks if a parent theme is defined

public hasSeedContent()

public hasSeedContent(): void

hasSeedContent returns true if some seed content is available

public isActiveTheme()

public isActiveTheme(): bool 

isActiveTheme returns true if this theme is the chosen active theme

public isLocked()

public isLocked(): bool 

isLocked returns true if the theme cannot be used

public listPages()

public listPages($skipCache = false): void

listPages returns a list of pages in the theme This method is used internally in the routing process and in the backend UI. Skipping cache indicates if the pages should be reloaded from the disk bypassing the cache.

public static load()

public static load($dirName): Cms\Classes\Theme 

load the theme

public registerHalcyonDatasource()

public registerHalcyonDatasource(): void

registerHalcyonDatasource ensures this theme is registered as a Halcyon datasource

public removeCustomData()

public removeCustomData(): bool 

removeCustomData removes data specific to this theme

public static resetCache()

public static resetCache(): void

resetCache resets any memory or cache involved with the active or edit theme

public static resetEditTheme()

public static resetEditTheme(): void

public secondLayerEnabled()

public secondLayerEnabled(): bool 

secondLayerEnabled is true if two or more datasources exist

public static setActiveTheme()

public static setActiveTheme($code): void

setActiveTheme sets the active theme

The active theme code is stored in the database and overrides the configuration cms.active_theme config item.

public setDirName()

public setDirName($dirName): void 

setDirName sets the theme directory name

public static setEditTheme()

public static setEditTheme($code): void

setEditTheme sets the editing theme

public themeIsCached()

public themeIsCached(): bool 

public useParentAsset()

public useParentAsset($relativePath): bool 

useParentAsset determines if a parent asset should be used

public writeConfig()

public writeConfig($values = [], $overwrite = false): void

writeConfig to the theme.yaml file with the supplied array values

Protected Methods

protected static getEditThemeCodeFromPreference()

protected static getEditThemeCodeFromPreference(): void

protected writeComposerFile()

protected writeComposerFile($data): void

writeComposerFile writes to a composer file for a theme