Magento 2 How to Remove a Top Link Using Layout ifconfig
-
03-10-2020 - |
質問
In Magento 2 how can I remove a link from top.links
via layout? I am assuming you can do this because every link is block in the top.links node is a its own block.
This is was a question I had earlier today. Because there is little information on this I will answer my own question and hopefully this will be of help for other people.
解決
Lets say if you want to remove the sign in link. You first need to find out the parent block, then create a conditional action (using the ifconfig attribute) to unset a child block and then pass the alias/name of the child block as an argument.
<referenceBlock name="top.links">
<action method="unsetChild" ifconfig="section_id/group/enabled">
<argument name="alias" xsi:type="string">authorization-link</argument>
</action>
</referenceBlock>
Note: ifconfig only accepts true or false (1/0) and will only unset the child if the value is true.
所属していません magento.stackexchange