Using Magento 2.1.7 on Ubuntu 16.04.
I have a layout file in my custom theme (<my_theme_dir>/Magento_Theme/layout/default.xml
) that removes a couple of footer links, adds a couple others, and specifies an the order for all of them. However, this order is ignored for the blocks that are only referenced in the file, rather than being fully present. Example:
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceBlock name="footer_links">
<referenceBlock name="privacy-policy-link" remove="true" />
<referenceBlock name="search-term-popular-link" remove="true" />
<block class="Magento\Framework\View\Element\Html\Link\Current" name="my-link-name" before="-">
<arguments>
<argument name="label" xsi:type="string">My Link</argument>
<argument name="path" xsi:type="string">my-link-path</argument>
</arguments>
</block>
<referenceBlock name="catalog-search-advanced-link" before="sales-guest-form-link" after="" />
<referenceBlock name="sales-guest-form-link" before="contact-us-link" after="" />
<referenceBlock name="contact-us-link" after="-" />
</referenceBlock>
</body>
</page>
This results in the following order:
- My link
- Contact Us
- Orders and Returns
- Advanced Search
Which is not the order I specified. However, if I change the "contact us" block so that it's defined fully within the current file:
<block class="Magento\Framework\View\Element\Html\Link\Current" ifconfig="contact/contact/enabled" name="contact-us-link">
<arguments>
<argument name="label" xsi:type="string" translate="true">Contact Us</argument>
<argument name="path" xsi:type="string">contact</argument>
</arguments>
</block>
it moves to the bottom as I would expect.
This leads me to believe that I simply can't use the before
and after
attributes to order blocks that are only referenced. They have to be defined in full for that to work.
This seems less than ideal to me, since if one of those blocks is changed in a future update or something, my override won't know and will continue to display it as it used to be. Is this not worth worrying about? Or is there a way to specify order when some blocks are locally-defined and some are referenced?