Magento 2 : Get value from system configuration in layout XML
-
05-10-2020 - |
Question
how do I get my module link identifier in the footer from the core config values I set in the admin system configuration
<referenceBlock name="footer_links">
<block class="Magento\Framework\View\Element\Html\Link\Current" name="storelocator-policy-link">
<arguments >
<argument ifconfig="googlemapsstorelocator/general/enable" name="label" xsi:type="string">Google Maps Store Locator</argument>
<argument name="path" xsi:type="string">I need this value form the configuration settings</argument>
</arguments>
</block>
</referenceBlock>
Solution
You have to write a "helper" (a method in any class of your module) and use xsi:type="helper
as described here: How to get output from helper for path argument in layout?
You should do the same for the first argument, because the argument
element cannot have an ifconfig
attribute (or move ifconfig
to the block
to not add it at all if the "enable" configuration is not set).
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange