Craft Themes (3.x)

FieldDisplayerInterface extends DisplayerInterface

A displayer renders one and one only type of field, it can have options.

Table of Contents

CACHE_PREFIX  = 'field'
Prefix used when caching this type of displayers
beforeRender()  : bool
Callback before rendering, returning false will skip the field rendering.
eagerLoad()  : array<string|int, string>
Modify eager load map
getCanBeCached()  : bool
Can this displayer be cached
getDescription()  : string
Description/helper shown in CP
getField()  : FieldInterface
Field getter
getFieldTargets()  : array<string|int, string>
Field classes this displayer can handle.
getHandle()  : string
Get handle
getHasOptions()  : bool
Does this displayer define options
getName()  : string
Get name
getOptions()  : FieldDisplayerOptions
Get options
getTheme()  : ThemeInterface
Theme getter
isDefault()  : bool
Is this displayer the default for a field class
setField()  : mixed
Field setter
setOptions()  : mixed
Options setter

Constants

Methods

beforeRender()

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

public beforeRender( &$value) : bool

The value will be null when this is called for a cached content block.

Parameters
$value :
Return values
bool

eagerLoad()

Modify eager load map

public eagerLoad(array<string|int, string> $eagerLoad[, string $prefix = '' ], int $level) : array<string|int, string>
Parameters
$eagerLoad : array<string|int, string>
$prefix : string = ''
$level : int
Return values
array<string|int, string>

getCanBeCached()

Can this displayer be cached

public getCanBeCached() : bool
Return values
bool

getDescription()

Description/helper shown in CP

public getDescription() : string
Return values
string

getFieldTargets()

Field classes this displayer can handle.

public static getFieldTargets() : array<string|int, string>

Developers should use FieldDisplayerService::getFieldTargets($displayerHandle) instead.

Return values
array<string|int, string>

getHandle()

Get handle

public static getHandle() : string
Return values
string

getHasOptions()

Does this displayer define options

public getHasOptions() : bool
Return values
bool

isDefault()

Is this displayer the default for a field class

public static isDefault(string $fieldClass) : bool
Parameters
$fieldClass : string
Return values
bool

setOptions()

Options setter

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

Search results