Attributes for blocks and containers used in layouts xml file

Blocks and Containers are heart of layout. Whenever we want to customise the page layout we do change in layout files or alter templates. Today we gonna list down all the attributes used in the layout xml.

Common layout instructions

Use the following layout instructions to customise your layout:

block

Defines a block.

Details: A block is a unit of page output that renders some distinctive content – a piece of information, a user interface element – anything visually tangible for the end-user.

AttributeDescriptionValuesRequired?
className of a class that implements rendering of a particular block. An object of this class is responsible for actual rendering of block output.class nameno (2.2.1 onwards)
nameName that can be used to address the block to which this attribute is assigned. The name must be unique per generated page. If not specified, an automatic name will be assigned in the format ANONYMOUS_n0-9, A-Z, a-z, underscore (_), period (.), dash (-). Should start with a letter. Case-sensitive.no
beforeUsed to position the block

before an element under the same parent. The element name or alias name is specified in the value. Use dash (-) to position the block before all other elements of its level of nesting. See before and after attributes for details.

Possible values: element name or dash (-)no
afterUsed to position the block after an element under the same parent. The element name or alias name is specified in the value. Use dash (-) to position the block after all other elements of its level of nesting. See before and after attributes for details.Possible values: element name or dash (-)no
templateA template that represents the functionality of the block to which this attribute is assigned.template file nameno
asAn alias name that serves as identifier in the scope of the parent element.0-9, A-Z, a-z, underscore (_), period (.), dash (-). Case-sensitive.no
cacheableDefines whether a block element is cacheable. This can be used for development purposes and to make needed elements of the page dynamic.true or falseno

container

A structure without content that holds other layout elements such as blocks and containers.

Details: A container renders child elements during view output generation. It can be empty or it can contain an arbitrary set of <container> and <block>elements.

AttributeDescriptionValuesRequired?
nameA name that can be used to address the container in which this attribute is assigned. The name must be unique per generated page.A-Z, a-z, 0-9, underscore (_), period (.), dash (-). Should start with a letter. Case-sensitive.no
labelAn arbitrary name to display in the web browser.anyno
beforeUsed to position the container before an element under the same parent. The element name or alias name is specified in the value. Use dash (-) to position the block before all other elements of its level of nesting. See before and after attributes for details.Possible values: element name or dash (-).no
afterUsed to position the container after an element under the same parent. The element name or alias name is specified in the value. Use dash (-) to position the block after all other elements of its level of nesting. See before and after attributes for details.Possible values: element name or dash (-).no
asAn alias name that serves as identifier in the scope of the parent element.0-9, A-Z, a-z, underscore (_), period (.), dash (-). Case-sensitive.no
outputDefines whether to output the root element. If specified, the element will be added to output list. (If not specified, the parent element is responsible for rendering its children.)Any value except the obsolete toHtml. Recommended value is 1.no
htmlTagOutput parameter. If specified, the output is wrapped into specified HTML tag.Any valid HTML 5 tag.no
htmlIdOutput parameter. If specified, the value is added to the wrapper element. If there is no wrapper element, this attribute has no effect.Any valid HTML 5 id value.no
htmlClassOutput parameter. If specified, the value is added to the wrapper element. If there is no wrapper element, this attribute has no effect.Any valid HTML 5 class value.no