Skip to content

XML instruction referenceBlock does not allow template= or does it? #9771

Closed
@jissereitsma

Description

@jissereitsma

Within the XML layout, you can reference a block using a <referenceBlock name="foobar"> statement. By manipulating its arguments (recommended) and actions (deprecated) you can update the template property just fine. However, the documentation http://devdocs.magento.com/guides/v2.0/frontend-dev-guide/layouts/xml-manage.html#set_template mentions you can also use the following syntax:

 <referenceBlock name="example" template="example.phtml" />

When I try this, it works just fine. However, when opening up XML layout in PhpStorm, which is setup to respect the XSD of urn:magento:module:View/Layout:etc/page_configuration.xsd, it is mentioned that the template parameter is not allowed within a referenceBlock.

This either means that the documentation is incorrect or that the XSD is incorrect. I would suggest that the XSD is incorrect, because setting the template this way is useful.

Preconditions

I've been seeing this in all of the Magento 2.1 versions I've worked with. However, I also remember this used to work one time as well.

Suggested fix

Within the file Magento_Framework/View/Layout/etc/elements.xsd there is a definition for blockReferenceType. Here the definition should include an additional line to allow for an optional argument template:

<xs:attribute type="xs:boolean" name="template" use="optional"/>

Metadata

Metadata

Assignees

No one assigned

    Labels

    Fixed in 2.2.xThe issue has been fixed in 2.2 release lineIssue: Format is not validGate 1 Failed. Automatic verification of issue format is failedIssue: Ready for WorkGate 4. Acknowledged. Issue is added to backlog and ready for development

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions