0

I try to replace the footer with my own, but I have no clue how.

I activated template hints, but it does not show any hint if this is a static block.

enter image description here

How can I modify this ?

  • That is not static block but that links you can add same as My account dashboard section. – Kishan Savaliya Nov 4 at 12:26
  • Im not sure what you mean. – Black Nov 4 at 12:30
  • You want to update any links or you want to add/remove links ? – Kishan Savaliya Nov 4 at 12:31
  • I want to add/remove links. – Black Nov 4 at 12:36
  • I've added my answer with output, let me know if you want any more information. – Kishan Savaliya Nov 4 at 12:46
1

You can check this file in vendor directory.

vendor/magento/module-theme/view/frontend/layout/default.xml

In above file footer_links block created under footer-container section. In default Luma theme you can see below five links in footer section.

  • Search Terms
  • Privacy and Cookie Policy
  • Advanced Search
  • Orders and Returns
  • Contact Us

All above links are coming from different files.

Search Terms link coming from this file..

vendor/magento/module-search/view/frontend/layout/default.xml

Privacy and Cookie Policy link from..

vendor/magento/module-cms/view/frontend/layout/default.xml

and so on..

If you want to remove any link or you want to update link's action URL/Path then you need to create default.xml file in your custom module or custom theme.

For e.g. if you want to remove "Search Terms" link and you want to update label of "Orders and Returns" to "Returns" and you want to add new link then you can do this..

Create default.xml file here in your custom theme.

app/design/frontend/Vendor/Theme/Magento_Theme/layout/default.xml

Content for this file is..

<?xml version="1.0" encoding="UTF-8"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
   <body>
      <referenceBlock name="search-term-popular-link" remove="true" /> <!-- This will remove "Search Terms" link -->
      <referenceBlock name="footer_links"> <!-- This block will change label from "Orders and Returns" to "Returns" -->
            <block class="Magento\Sales\Block\Guest\Link" name="sales-guest-form-link">
                <arguments>
                    <argument name="label" xsi:type="string" translate="true">Returns</argument>
                    <argument name="path" xsi:type="string">sales/guest/form</argument>
                </arguments>
            </block>
            <!-- Below code is useful to add new "Custom link" in footer links -->
            <block class="Magento\Framework\View\Element\Html\Link\Current" name="new-custom-link">
                <arguments>
                    <argument name="label" xsi:type="string" translate="true">New Custom Link</argument>
                    <argument name="path" xsi:type="string">new/custom/url</argument>
                </arguments>
            </block>
        </referenceBlock>
   </body>
</page>

Output :

enter image description here

Hope this will help you!

  • Thank you for the detailed explanation. It really helped me to understand it. – Black Nov 4 at 12:52
  • 1
    You're most welcome buddy! :) – Kishan Savaliya Nov 4 at 12:53
  • I have one question left. How did you knew that you have to use search-term-popular-link for referenceBlock? – Black Nov 4 at 13:44
  • 1
    You can find that block in this xml file. vendor/magento/module-search/view/frontend/layout/default.xml – Kishan Savaliya Nov 4 at 13:49
  • 1
    First of all I see the link start with search so that is relevant to Search modules, so I go to vendor/magento /module-search directory and confirmed it's router for frontend. After that I checked XML files. Same thing you can do for contact us link that is relevant to contact module. – Kishan Savaliya Nov 4 at 13:56
1

It's a block (name: footer_links) which just render set of children blocks, base declaration you can find in vendor/magento/module-theme/view/frontend/layout/default.xml:123

How to add new link:

        <referenceBlock name="footer_links">
            <block class="Magento\Framework\View\Element\Html\Link\Current" ifconfig="catalog/seo/search_terms" name="search-term-popular-link">
                <arguments>
                    <argument name="label" xsi:type="string" translate="true">Search Terms</argument>
                    <argument name="path" xsi:type="string">search/term/popular</argument>
                </arguments>
            </block>
        </referenceBlock>

How to remove link:

<referenceBlock name="search-term-popular-link" remove="true" />

which will remove first link on your screen.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.