Skip to content

XML syntax to change block's template #3356

@cescopag

Description

@cescopag

Summary

Documentation claims that it is possible to change a block's template by the following layout update:

<referenceBlock name="navigation.sections">
  <arguments>
    <argument name="template" xsi:type="string">Magento_Theme::html/nav_sections.phtml</argument>
  </arguments>
</referenceBlock>

But It doesn't work.

Using action node, instead of arguments node, works fine:

<referenceBlock name="navigation.sections">
  <action method="setTemplate">
    <argument name="template" xsi:type="string">Magento_Theme::html/nav_sections.phtml</argument>
  </action>
</referenceBlock>

Source:
http://devdocs.magento.com/guides/v2.0/frontend-dev-guide/layouts/xml-manage.html#set_template

Preconditions (*)

  1. Magento 2.3-develop
  2. PHP 7.2

Steps to reproduce (*)

Try to change a block's template by the following layout update
e.g.:
3356

Expected result (*)

Block's template is changed without any errors

Actual result (*)

Got exception
3356ex

Metadata

Metadata

Assignees

Labels

Area: FrontendComponent: Framework/CodeComponent: ThemeIssue: Clear DescriptionGate 2 Passed. Manual verification of the issue description passedIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedIssue: Format is validGate 1 Passed. Automatic verification of issue format passedIssue: Ready for WorkGate 4. Acknowledged. Issue is added to backlog and ready for developmentProgress: doneReproduced on 2.2.xThe issue has been reproduced on latest 2.2 releaseReproduced on 2.3.xThe issue has been reproduced on latest 2.3 releaseTriage: Dev.ExperienceIssue related to Developer Experience and needs help with Triage to Confirm or Reject itbug report

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions