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.

Protected properties

protected string $dirName

dirName specifies the theme directory name

protected mixed $configCache

configCache keeps the cached configuration file values

protected static mixed $activeThemeCache

activeThemeCache in memory

protected static mixed $editThemeCache

editThemeCache in memory

Public methods

public void __get($name)

__get magic

  • $name

public void __isset($key)

__isset magic

  • $key

public static void all()

all returns all themes on disk

public static void allAvailable()

allAvailable returns all available themes, those that are not locked

public void databaseLayerEnabled()

databaseLayerEnabled checks global and local config

public static void exists($dirName)

exists determines if a theme with given directory name exists

  • $dirName

public static void getActiveTheme()

getActiveTheme returns the active theme object

public static void getActiveThemeCode()

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 void getConfig()

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

public void getConfigArray($name)

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.

  • $name

public void getConfigValue($name, $default=NULL)

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

  • $name
  • $default

public void getCustomData()

getCustomData returns data specific to this theme

public void getDatasource()

getDatasource returns the theme's datasource

public void getDirName()

getDirName returns the theme directory name

public static void getEditTheme()

getEditTheme returns the edit theme

public static void getEditThemeCode()

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 void getFormConfig()

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 void getId()

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

public void getParentOptions()

getParentOptions returns dropdown options for a parent theme

public void getParentTheme()

getParentTheme returns a parent theme, if enabled

public void getPath($dirName=NULL)

getPath returns the absolute theme path.

  • $dirName

public void getPreviewImageUrl()

getPreviewImageUrl returns the theme preview image URL

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

public void hasCustomData()

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

public void hasParentTheme()

hasParentTheme checks if a parent theme is defined

public void isActiveTheme()

isActiveTheme returns true if this theme is the chosen active theme

public void isLocked()

isLocked returns true if the theme cannot be used

public void listPages($skipCache=false)

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

  • $skipCache

public static void load($dirName)

load the theme

  • $dirName

public void registerHalyconDatasource()

registerHalyconDatasource ensures this theme is registered as a Halcyon datasource

public void removeCustomData()

removeCustomData removes data specific to this theme

public static void resetCache()

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

public void secondLayerEnabled()

secondLayerEnabled is true if two or more datasources exist

public static void setActiveTheme($code)

setActiveTheme sets the active theme

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

  • $code

public void setDirName($dirName)

setDirName sets the theme directory name

  • $dirName

public static void setEditTheme($code)

setEditTheme sets the editing theme

  • $code

public void useParentAsset($relativePath)

useParentAsset determines if a parent asset should be used

  • $relativePath

public void writeConfig($values=array(), $overwrite=false)

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

  • $values
  • $overwrite

Protected methods

protected void writeComposerFile($data)

writeComposerFile writes to a composer file for a theme

  • $data