Craft Themes (3.x)

ThemeInterface

A theme is a regular plugin, it defines regions and can extend another theme.

They can be partials. They define preferences for rendering page elements.

Table of Contents

afterSet()  : mixed
Callback after the theme has been set for a request
afterThemeInstall()  : mixed
Callback after the plugin is installed, this is only called for pro version.
afterThemeUninstall()  : mixed
Callback after the plugin is uninstalled.
getAssetUrl()  : string
Get an url for an theme asset.
getExtends()  : string|null
Which other theme does this extends from.
getHasPreview()  : bool
Does this theme have a preview image
getParent()  : ThemeInterface|null
Get theme parent
getPreferences()  : ThemePreferencesInterface
Get theme preferences
getPreviewImage()  : string
Preview image for the theme, returns a web url
getRegions()  : array<string|int, mixed>
Get theme's regions definitions
getRegionsTemplate()  : string
Get the base template for rendering regions
getScssCompiler()  : Compiler
Get the scss compiler.
getTemplatePaths()  : array<string|int, string>
Absolute template paths, including those of the parent(s)
getTemplatesFolder()  : string
Folder where the templates are stored for this theme
isPartial()  : bool
Is this theme partial.
registerAssetBundles()  : mixed
Register this theme's assets in view for a specific path

Methods

afterSet()

Callback after the theme has been set for a request

public afterSet() : mixed
Return values
mixed

afterThemeInstall()

Callback after the plugin is installed, this is only called for pro version.

public afterThemeInstall() : mixed

At this point the theme data (layouts etc) is installed.

Return values
mixed

afterThemeUninstall()

Callback after the plugin is uninstalled.

public afterThemeUninstall() : mixed

At this point the theme data (layouts etc) is uninstalled.

Return values
mixed

getAssetUrl()

Get an url for an theme asset.

public getAssetUrl(string $path) : string
Parameters
$path : string
Return values
string

getExtends()

Which other theme does this extends from.

public getExtends() : string|null

Returns a plugin handle.

Return values
string|null

getHasPreview()

Does this theme have a preview image

public getHasPreview() : bool
Return values
bool

getPreviewImage()

Preview image for the theme, returns a web url

public getPreviewImage() : string
Return values
string

getRegions()

Get theme's regions definitions

public getRegions() : array<string|int, mixed>
Return values
array<string|int, mixed>

getRegionsTemplate()

Get the base template for rendering regions

public getRegionsTemplate() : string
Return values
string

getScssCompiler()

Get the scss compiler.

public getScssCompiler([array<string|int, mixed> $options = [] ]) : Compiler

To ensure paths inheritance for parent themes is kept, compiler option importPaths must be set here. The compiler defined here will be used for asset bundle scss, inline scss and files, and command line compilations.

Parameters
$options : array<string|int, mixed> = []

Override compiler options here. Import paths will be prepended, aliases will be overridden

Return values
Compiler

getTemplatePaths()

Absolute template paths, including those of the parent(s)

public getTemplatePaths() : array<string|int, string>
Return values
array<string|int, string>

getTemplatesFolder()

Folder where the templates are stored for this theme

public getTemplatesFolder() : string
Return values
string

isPartial()

Is this theme partial.

public isPartial() : bool

Partial themes can't be selected for front end, their purpose is only to be inherited from

Return values
bool

registerAssetBundles()

Register this theme's assets in view for a specific path

public registerAssetBundles(string $urlPath) : mixed
Parameters
$urlPath : string
Return values
mixed

Search results