LayoutInterface
in
A layout is associated to a theme and unless it's a custom layout, to a Craft element.
Those elements can be : entry type, category group, global set, volume, tag group or user layout. Layouts have regions, as defined by their theme.
Table of Contents
- RENDER_MODE_DISPLAYS = 'displays'
- RENDER_MODE_REGIONS = 'regions'
- addBlock() : LayoutInterface
- Add a block
- addViewMode() : LayoutInterface
- Add a view mode
- canHaveBlocks() : bool
- Can this layout be assigned blocks
- 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)
- 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
- 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.
- 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
Constants
RENDER_MODE_DISPLAYS
public
mixed
RENDER_MODE_DISPLAYS
= 'displays'
RENDER_MODE_REGIONS
public
mixed
RENDER_MODE_REGIONS
= 'regions'
Methods
addBlock()
Add a block
public
addBlock(BlockInterface $block, string $region) : LayoutInterface
Parameters
- $block : BlockInterface
- $region : string
Return values
LayoutInterface —addViewMode()
Add a view mode
public
addViewMode(ViewModeInterface $viewMode) : LayoutInterface
Parameters
- $viewMode : ViewModeInterface
Return values
LayoutInterface —canHaveBlocks()
Can this layout be assigned blocks
public
canHaveBlocks() : bool
Return values
bool —getBlocks()
Blocks getter
public
getBlocks() : array<string|int, BlockInterface>
Return values
array<string|int, BlockInterface> —getBlockTemplates()
Get available templates for a block
public
getBlockTemplates(BlockInterface $block) : array<string|int, mixed>
Parameters
- $block : BlockInterface
Return values
array<string|int, mixed> —getConfig()
Get project config
public
getConfig() : array<string|int, mixed>
Return values
array<string|int, mixed> —getCraftFields()
Get all craft fields defined on this layout's element
public
getCraftFields() : array<string|int, Field>
Return values
array<string|int, Field> —getDefaultViewMode()
Get default view mode
public
getDefaultViewMode() : ViewModeInterface
Return values
ViewModeInterface —getDescription()
Get description
public
getDescription() : string
Return values
string —getEditBlocksUrl()
Get the url to edit blocks.
public
getEditBlocksUrl() : string
Returns the blocks url for the default layout if this layout doesn't have blocks
Return values
string —getEditDisplaysUrl()
Get the url to edit displays for a view mode.
public
getEditDisplaysUrl([ViewModeInterface|string|null $viewMode = null ]) : string|null
Returns null if the layout doesn't have displays. Takes the default view mode if $viewMode is null
Parameters
- $viewMode : ViewModeInterface|string|null = null
Return values
string|null —getElement()
Get element associated to that layout (category group, entry type, User etc)
public
getElement() : mixed
Return values
mixed —getFieldLayout()
Get layout's element field layout
public
getFieldLayout() : FieldLayout
Return values
FieldLayout —getFieldTemplates()
Get available templates for a field
public
getFieldTemplates(FieldInterface $field) : array<string|int, mixed>
Parameters
- $field : FieldInterface
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
Return values
array<string|int, mixed> —getGroupTemplates()
Get available templates for a group
public
getGroupTemplates(GroupInterface $group) : array<string|int, mixed>
Parameters
- $group : GroupInterface
Return values
array<string|int, mixed> —getParent()
Parent getter
public
getParent() : LayoutInterface|null
Return values
LayoutInterface|null —getRegion()
Get a region by handle.
public
getRegion(string $handle) : Region
Parameters
- $handle : string
Return values
Region —getRegions()
Get layout regions
public
getRegions() : array<string|int, RegionInterface>
Return values
array<string|int, RegionInterface> —getRegionTemplates()
Get available templates for a region
public
getRegionTemplates(RegionInterface $region) : array<string|int, mixed>
Parameters
- $region : RegionInterface
Return values
array<string|int, mixed> —getTemplates()
Get available templates
public
getTemplates(ViewModeInterface $viewMode) : array<string|int, mixed>
Parameters
- $viewMode : ViewModeInterface
Return values
array<string|int, mixed> —getTemplatingKey()
Get the portion of template name associated with this element.
public
getTemplatingKey() : string
This would be 'blog-article' for an entry type 'article' of a section 'blog'. Or 'authors' for a category group 'authors' Etc
Return values
string —getTheme()
Get this layout's theme
public
getTheme() : ThemeInterface
Return values
ThemeInterface —getType()
Type getter
public
getType() : string
Return values
string —getViewMode()
Get view mode by handle
public
getViewMode(string $handle) : ViewModeInterface|null
Parameters
- $handle : string
Return values
ViewModeInterface|null —getViewModes()
Get view modes defined for that layout
public
getViewModes() : array<string|int, ViewModeInterface>
Return values
array<string|int, ViewModeInterface> —hasDisplays()
Can this layout define displays.
public
hasDisplays() : bool
Default and custom layout can't have displays since it doesn't have an element associated to it.
Return values
bool —hasRegion()
Is a region defined
public
hasRegion(string $handle) : bool
Parameters
- $handle : string
Return values
bool —hasViewMode()
Is a view mode handle defined in this layout
public
hasViewMode(string $handle) : bool
Parameters
- $handle : string
Return values
bool —render()
Render this layout for an element
public
render(Element $element[, string|ViewModeInterface $viewMode = ViewModeService::DEFAULT_HANDLE ]) : Markup
Parameters
- $element : Element
- $viewMode : string|ViewModeInterface = ViewModeService::DEFAULT_HANDLE
Return values
Markup —renderRegions()
Render this layout's regions
public
renderRegions() : Markup
Return values
Markup —setBlocks()
Blocks setter
public
setBlocks(array<string|int, BlockInterface> $blocks) : LayoutInterface
Parameters
- $blocks : array<string|int, BlockInterface>
Return values
LayoutInterface —setElement()
Set element associated to that layout
public
setElement(mixed $element) : mixed
Parameters
- $element : mixed
Return values
mixed —setParent()
Parent setter
public
setParent(LayoutInterface $layout) : mixed
Parameters
- $layout : LayoutInterface
Return values
mixed —setViewModes()
View modes setter
public
setViewModes(null|array<string|int, ViewModeInterface> $viewModes) : LayoutInterface
Parameters
- $viewModes : null|array<string|int, ViewModeInterface>