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|null
- Only used for custom layouts
- $parent_id : int|null
- $themeHandle : string
- $uid : string
- $_element : mixed
- Element associated with this layout (entry type, user, category group etc)
- $_parent : LayoutInterface|null
- $_regionLayoutHandle : string
- $_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() : array<string|int, 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.
- getRegionLayout() : RegionLayoutInterface
- Get this layout regions layout
- getRegionLayoutHandle() : string
- Get the region layout 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() : bool
- 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
- setRegionLayoutHandle() : mixed
- Set the region layout handle. This will rebuild all the regions, therefore remove all the blocks !
- 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
$id
public
id
$id
$name
Only used for custom layouts
public
string|null
$name
$parent_id
public
int|null
$parent_id
$themeHandle
public
string
$themeHandle
$uid
public
string
$uid
$_element
Element associated with this layout (entry type, user, category group etc)
protected
mixed
$_element
$_parent
protected
LayoutInterface|null
$_parent
$_regionLayoutHandle
protected
string
$_regionLayoutHandle
Tags
$_regions
protected
array<string|int, RegionInterface>
$_regions
$_viewModes
protected
array<string|int, ViewModeInterface>
$_viewModes
$fieldLayoutIdAttribute
Attribute that stores the field layout id
protected
string
$fieldLayoutIdAttribute
= 'fieldLayoutId'
Methods
addBlock()
Add a block
public
addBlock(BlockInterface $block, string $region) : LayoutInterface
Parameters
- $block : BlockInterface
- $region : string
Tags
Return values
LayoutInterface —addViewMode()
Add a view mode
public
addViewMode(ViewModeInterface $viewMode) : LayoutInterface
Parameters
- $viewMode : ViewModeInterface
Tags
Return values
LayoutInterface —afterValidate()
public
afterValidate() : mixed
Tags
Return values
mixed —canHaveBlocks()
Can this layout be assigned blocks
public
canHaveBlocks() : bool
Tags
Return values
bool —defineRules()
public
defineRules() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —fields()
public
fields() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —getBlocks()
Blocks getter
public
getBlocks() : array<string|int, BlockInterface>
Tags
Return values
array<string|int, BlockInterface> —getBlockTemplates()
Get available templates for a block
public
getBlockTemplates(BlockInterface $block) : array<string|int, mixed>
Parameters
- $block : BlockInterface
Tags
Return values
array<string|int, mixed> —getConfig()
Get project config
public
getConfig() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —getCraftFields()
Get all craft fields defined on this layout's element
public
getCraftFields() : array<string|int, Field>
Tags
Return values
array<string|int, Field> —getDefaultViewMode()
Get default view mode
public
getDefaultViewMode() : ViewModeInterface
Tags
Return values
ViewModeInterface —getDescription()
Get description
public
getDescription() : string
Tags
Return values
string —getEditBlocksUrl()
Get the url to edit blocks.
public
getEditBlocksUrl() : string
Tags
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
Return values
string|null —getElement()
Get element associated to that layout (category group, entry type, User etc)
public
getElement() : mixed
Tags
Return values
mixed —getErrors()
public
getErrors([mixed $attribute = null ]) : mixed
Parameters
- $attribute : mixed = null
Tags
Return values
mixed —getFieldLayout()
Get layout's element field layout
public
getFieldLayout() : FieldLayout
Tags
Return values
FieldLayout —getFieldTemplates()
Get available templates for a field
public
getFieldTemplates(FieldInterface $field) : array<string|int, mixed>
Parameters
- $field : FieldInterface
Tags
Return values
array<string|int, mixed> —getFileTemplates()
Get available templates for a file
public
getFileTemplates(FieldInterface $field, FileDisplayerInterface $displayer) : array<string|int, mixed>
Parameters
- $field : FieldInterface
- $displayer : FileDisplayerInterface
Tags
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
Return values
array<string|int, mixed> —getIsCustom()
Is custom getter
public
getIsCustom() : bool
Return values
bool —getParent()
Parent getter
public
getParent() : LayoutInterface|null
Tags
Return values
LayoutInterface|null —getRegion()
Get a region by handle.
public
getRegion(string $handle) : Region
Parameters
- $handle : string
Tags
Return values
Region —getRegionLayout()
Get this layout regions layout
public
getRegionLayout() : RegionLayoutInterface
Tags
Return values
RegionLayoutInterface —getRegionLayoutHandle()
Get the region layout handle
public
getRegionLayoutHandle() : string
Tags
Return values
string —getRegions()
Get layout regions
public
getRegions() : array<string|int, RegionInterface>
Tags
Return values
array<string|int, RegionInterface> —getRegionTemplates()
Get available templates for a region
public
getRegionTemplates(RegionInterface $region) : array<string|int, mixed>
Parameters
- $region : RegionInterface
Tags
Return values
array<string|int, mixed> —getTemplates()
Get available templates
public
getTemplates(ViewModeInterface $viewMode) : array<string|int, mixed>
Parameters
- $viewMode : ViewModeInterface
Tags
Return values
array<string|int, mixed> —getTemplatingKey()
Get the portion of template name associated with this element.
public
getTemplatingKey() : string
Tags
Return values
string —getTheme()
Get this layout's theme
public
getTheme() : ThemeInterface
Tags
Return values
ThemeInterface —getType()
Type getter
public
getType() : string
Tags
Return values
string —getViewMode()
Get view mode by handle
public
getViewMode(string $handle) : ViewModeInterface|null
Parameters
- $handle : string
Tags
Return values
ViewModeInterface|null —getViewModes()
Get view modes defined for that layout
public
getViewModes() : array<string|int, ViewModeInterface>
Tags
Return values
array<string|int, ViewModeInterface> —hasDisplays()
Can this layout define displays.
public
hasDisplays() : bool
Tags
Return values
bool —hasErrors()
public
hasErrors([mixed $attribute = null ]) : bool
Parameters
- $attribute : mixed = null
Tags
Return values
bool —hasRegion()
Is a region defined
public
hasRegion(string $handle) : bool
Parameters
- $handle : string
Tags
Return values
bool —hasViewMode()
Is a view mode handle defined in this layout
public
hasViewMode(string $handle) : bool
Parameters
- $handle : string
Tags
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
Return values
Markup —renderRegions()
Render this layout's regions
public
renderRegions() : Markup
Tags
Return values
Markup —setBlocks()
Blocks setter
public
setBlocks(array<string|int, mixed> $blocks) : LayoutInterface
Parameters
- $blocks : array<string|int, mixed>
Tags
Return values
LayoutInterface —setElement()
Set element associated to that layout
public
setElement(mixed $element) : mixed
Parameters
- $element : mixed
Tags
Return values
mixed —setParent()
Parent setter
public
setParent(LayoutInterface $layout) : mixed
Parameters
- $layout : LayoutInterface
Tags
Return values
mixed —setRegionLayoutHandle()
Set the region layout handle. This will rebuild all the regions, therefore remove all the blocks !
public
setRegionLayoutHandle(string|null $handle) : mixed
Parameters
- $handle : string|null
Tags
Return values
mixed —setViewModes()
View modes setter
public
setViewModes(array<string|int, mixed>|null $viewModes) : LayoutInterface
Parameters
- $viewModes : array<string|int, mixed>|null
Tags
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