Craft Themes (4.x)

BlockInterface

Defines a block. Blocks are defined by providers, they can have various options and can be assigned to theme's regions.

Table of Contents

afterSave()  : mixed
Callback after the block has been saved
beforeRender()  : bool
Callback before rendering, returning false will skip the block rendering.
getCacheStrategy()  : BlockCacheStrategyInterface|null
Get the cache strategy for this block
getCanBeCached()  : bool
Can this block be cached
getConfig()  : array<string|int, mixed>
Project config to be saved
getHandle()  : string
Get block handle
getLayout()  : LayoutInterface
Get layout object
getLongDescription()  : string
Long description getter
getMachineName()  : string
Get full machine name, in the form provider-handle
getName()  : string
Name getter
getOptions()  : BlockOptions
Get options model
getSmallDescription()  : string
Small description getter
getTemplates()  : array<string|int, string>
Get available templates
isVisible()  : bool
Is this block visible
provider()  : BlockProviderInterface
Get provider object
render()  : Markup
Render this block
setCacheStrategy()  : mixed
Set the cache strategy, $strategy should be an array : [ 'handle' => 'strategyHandle', 'options' => [] ]
setLayout()  : mixed
Set layout object
setOptions()  : mixed
Options setter

Methods

afterSave()

Callback after the block has been saved

public afterSave() : mixed
Return values
mixed

beforeRender()

Callback before rendering, returning false will skip the block rendering.

public beforeRender() : bool
Return values
bool

getCanBeCached()

Can this block be cached

public getCanBeCached() : bool
Return values
bool

getConfig()

Project config to be saved

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

getHandle()

Get block handle

public getHandle() : string
Return values
string

getLongDescription()

Long description getter

public getLongDescription() : string
Return values
string

getMachineName()

Get full machine name, in the form provider-handle

public getMachineName() : string
Return values
string

getName()

Name getter

public getName() : string
Return values
string

getSmallDescription()

Small description getter

public getSmallDescription() : string
Return values
string

isVisible()

Is this block visible

public isVisible() : bool
Return values
bool

render()

Render this block

public render() : Markup
Return values
Markup

setCacheStrategy()

Set the cache strategy, $strategy should be an array : [ 'handle' => 'strategyHandle', 'options' => [] ]

public setCacheStrategy(array<string|int, mixed> $strategy) : mixed
Parameters
$strategy : array<string|int, mixed>
Return values
mixed

setOptions()

Options setter

public setOptions(string|array<string|int, mixed> $options) : mixed
Parameters
$options : string|array<string|int, mixed>
Return values
mixed

Search results