Craft Themes (3.x)

Layout extends Model
in package
implements LayoutInterface

The default layout

Interfaces, Classes and Traits

LayoutInterface
A layout is associated to a theme and unless it's a custom layout, to a Craft element.

Table of Contents

$dateCreated  : DateTime
$dateUpdated  : DateTime
$elementUid  : string
$hasBlocks  : bool
$id  : id
$name  : string
Only used for custom layouts
$parent_id  : int
$themeHandle  : int
$uid  : string
$_element  : mixed
Element associated with this layout (entry type, user, category group etc)
$_parent  : LayoutInterface|null
$_regions  : array<string|int, RegionInterface>
$_viewModes  : array<string|int, ViewModeInterface>
$fieldLayoutIdAttribute  : string
Attribute that stores the field layout id
addBlock()  : LayoutInterface
Add a block
addViewMode()  : LayoutInterface
Add a view mode
afterValidate()  : mixed
canHaveBlocks()  : bool
Can this layout be assigned blocks
defineRules()  : array<string|int, mixed>
fields()  : mixed
getBlocks()  : array<string|int, BlockInterface>
Blocks getter
getBlockTemplates()  : array<string|int, mixed>
Get available templates for a block
getConfig()  : array<string|int, mixed>
Get project config
getCraftFields()  : array<string|int, Field>
Get all craft fields defined on this layout's element
getDefaultViewMode()  : ViewModeInterface
Get default view mode
getDescription()  : string
Get description
getEditBlocksUrl()  : string
Get the url to edit blocks.
getEditDisplaysUrl()  : string|null
Get the url to edit displays for a view mode.
getElement()  : mixed
Get element associated to that layout (category group, entry type, User etc)
getErrors()  : mixed
getFieldLayout()  : FieldLayout
Get layout's element field layout
getFieldTemplates()  : array<string|int, mixed>
Get available templates for a field
getFileTemplates()  : array<string|int, mixed>
Get available templates for a file
getGroupTemplates()  : array<string|int, mixed>
Get available templates for a group
getIsCustom()  : bool
Is custom getter
getParent()  : LayoutInterface|null
Parent getter
getRegion()  : Region
Get a region by handle.
getRegions()  : array<string|int, RegionInterface>
Get layout regions
getRegionTemplates()  : array<string|int, mixed>
Get available templates for a region
getTemplates()  : array<string|int, mixed>
Get available templates
getTemplatingKey()  : string
Get the portion of template name associated with this element.
getTheme()  : ThemeInterface
Get this layout's theme
getType()  : string
Type getter
getViewMode()  : ViewModeInterface|null
Get view mode by handle
getViewModes()  : array<string|int, ViewModeInterface>
Get view modes defined for that layout
hasDisplays()  : bool
Can this layout define displays.
hasErrors()  : mixed
hasRegion()  : bool
Is a region defined
hasViewMode()  : bool
Is a view mode handle defined in this layout
render()  : Markup
Render this layout for an element
renderRegions()  : Markup
Render this layout's regions
setBlocks()  : LayoutInterface
Blocks setter
setElement()  : mixed
Set element associated to that layout
setParent()  : mixed
Parent setter
setViewModes()  : LayoutInterface
View modes setter
validateElementUid()  : mixed
Validates elementUid attribute
validateThemeHandle()  : mixed
Validates themeHandle attribute
loadElement()  : mixed
Loads this layout associated element (category group, entry type etc)

Properties

$dateCreated

public DateTime $dateCreated

$dateUpdated

public DateTime $dateUpdated

$elementUid

public string $elementUid

$hasBlocks

public bool $hasBlocks = false

$name

Only used for custom layouts

public string $name

$parent_id

public int $parent_id

$themeHandle

public int $themeHandle

$_element

Element associated with this layout (entry type, user, category group etc)

protected mixed $_element

$fieldLayoutIdAttribute

Attribute that stores the field layout id

protected string $fieldLayoutIdAttribute = 'fieldLayoutId'

Methods

afterValidate()

public afterValidate() : mixed
Tags
inheritDoc
Return values
mixed

canHaveBlocks()

Can this layout be assigned blocks

public canHaveBlocks() : bool
Tags
inheritDoc
Return values
bool

defineRules()

public defineRules() : array<string|int, mixed>
Tags
inheritDoc
Return values
array<string|int, mixed>

fields()

public fields() : mixed
Tags
inheritDoc
Return values
mixed

getBlockTemplates()

Get available templates for a block

public getBlockTemplates(BlockInterface $block) : array<string|int, mixed>
Parameters
$block : BlockInterface
Tags
inheritDoc
Return values
array<string|int, mixed>

getConfig()

Get project config

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

getCraftFields()

Get all craft fields defined on this layout's element

public getCraftFields() : array<string|int, Field>
Tags
inheritDoc
Return values
array<string|int, Field>

getDescription()

Get description

public getDescription() : string
Tags
inheritDoc
Return values
string

getEditBlocksUrl()

Get the url to edit blocks.

public getEditBlocksUrl() : string
Tags
inheritDoc
Return values
string

getEditDisplaysUrl()

Get the url to edit displays for a view mode.

public getEditDisplaysUrl([mixed $viewMode = null ]) : string|null
Parameters
$viewMode : mixed = null
Tags
inheritDoc
Return values
string|null

getElement()

Get element associated to that layout (category group, entry type, User etc)

public getElement() : mixed
Tags
inheritDoc
Return values
mixed

getErrors()

public getErrors([mixed $attribute = null ]) : mixed
Parameters
$attribute : mixed = null
Tags
inheritDoc
Return values
mixed

getFieldLayout()

Get layout's element field layout

public getFieldLayout() : FieldLayout
Tags
inheritDoc
Return values
FieldLayout

getFieldTemplates()

Get available templates for a field

public getFieldTemplates(FieldInterface $field) : array<string|int, mixed>
Parameters
$field : FieldInterface
Tags
inheritDoc
Return values
array<string|int, mixed>

getGroupTemplates()

Get available templates for a group

public getGroupTemplates(GroupInterface $group) : array<string|int, mixed>
Parameters
$group : GroupInterface
Tags
inheritDoc
Return values
array<string|int, mixed>

getIsCustom()

Is custom getter

public getIsCustom() : bool
Return values
bool

getRegion()

Get a region by handle.

public getRegion(string $handle) : Region
Parameters
$handle : string
Tags
inheritDoc
Return values
Region

getRegionTemplates()

Get available templates for a region

public getRegionTemplates(RegionInterface $region) : array<string|int, mixed>
Parameters
$region : RegionInterface
Tags
inheritDoc
Return values
array<string|int, mixed>

getTemplates()

Get available templates

public getTemplates(ViewModeInterface $viewMode) : array<string|int, mixed>
Parameters
$viewMode : ViewModeInterface
Tags
inheritDoc
Return values
array<string|int, mixed>

getTemplatingKey()

Get the portion of template name associated with this element.

public getTemplatingKey() : string
Tags
inheritDoc
Return values
string

getType()

Type getter

public getType() : string
Tags
inheritDoc
Return values
string

hasDisplays()

Can this layout define displays.

public hasDisplays() : bool
Tags
inheritDoc
Return values
bool

hasErrors()

public hasErrors([mixed $attribute = null ]) : mixed
Parameters
$attribute : mixed = null
Tags
inheritDoc
Return values
mixed

hasRegion()

Is a region defined

public hasRegion(string $handle) : bool
Parameters
$handle : string
Tags
inheritDoc
Return values
bool

hasViewMode()

Is a view mode handle defined in this layout

public hasViewMode(string $handle) : bool
Parameters
$handle : string
Tags
inheritDoc
Return values
bool

render()

Render this layout for an element

public render(Element $element[, mixed $viewMode = ViewModeService::DEFAULT_HANDLE ]) : Markup
Parameters
$element : Element
$viewMode : mixed = ViewModeService::DEFAULT_HANDLE
Tags
inheritDoc
Return values
Markup

renderRegions()

Render this layout's regions

public renderRegions() : Markup
Tags
inheritDoc
Return values
Markup

setBlocks()

Blocks setter

public setBlocks(array<string|int, mixed> $blocks) : LayoutInterface
Parameters
$blocks : array<string|int, mixed>
Tags
inheritDoc
Return values
LayoutInterface

setElement()

Set element associated to that layout

public setElement(mixed $element) : mixed
Parameters
$element : mixed
Tags
inheritDoc
Return values
mixed

setViewModes()

View modes setter

public setViewModes(array<string|int, mixed>|null $viewModes) : LayoutInterface
Parameters
$viewModes : array<string|int, mixed>|null
Tags
inheritDoc
Return values
LayoutInterface

validateElementUid()

Validates elementUid attribute

public validateElementUid() : mixed
Return values
mixed

validateThemeHandle()

Validates themeHandle attribute

public validateThemeHandle() : mixed
Return values
mixed

loadElement()

Loads this layout associated element (category group, entry type etc)

protected loadElement() : mixed
Return values
mixed

Search results