0

I have created a custom module and then created default.xml in app/code/Test/Mymodule/view/frontend/layout:

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
     <referenceBlock name="privacy-policy-link" remove="true">
     <referenceBlock name="footer_links">
         <block class="Magento\Framework\View\Element\Html\Link\Current" name="custom-link">
             <arguments>
                 <argument name="label" xsi:type="string">Footer Link</argument>
                 <argument name="path" xsi:type="string">testuser</argument>
             </arguments>
         </block>
     </referenceBlock>
</body>
</page>

But its not showing the result.

1

By Default Magento2 provides some footer links. We need to remove them first. Then create a content block from admin site using the key footer_links_block and need to integrate it. For these changes you should create a file

app/design/frontend/<vender name>/<theme name>/Magento_Theme/layout/default.xml

then place below code into the xml

<?xml version="1.0"?>
<!--
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
-->
<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" remove="true"/>
        <referenceContainer name="header.panel">
            <block class="Magento\Framework\View\Element\Html\Links" name="header.links">
                <arguments>
                    <argument name="css_class" xsi:type="string">header links</argument>
                </arguments>
            </block>
        </referenceContainer>
        <referenceContainer name="footer">
            <block class="Magento\Cms\Block\Block" name="footer_links_block">
                <arguments>
                    <argument name="block_id" xsi:type="string">footer_links_block</argument>
                </arguments>
            </block>
            <block class="Magento\Store\Block\Switcher" name="store_switcher" as="store_switcher" after="footer_links" template="Magento_Store::switch/stores.phtml"/>
        </referenceContainer>
        <referenceBlock name="report.bugs" remove="true"/>
        <move element="copyright" destination="before.body.end"/>
    </body>
</page>

In Detail, From XML below line is used to remove default footer links

<referenceBlock name="footer_links" remove="true"/>

Below line is used to integrate the content block with key footer_links_block

<block class="Magento\Cms\Block\Block" name="footer_links_block">
                <arguments>
                    <argument name="block_id" xsi:type="string">footer_links_block</argument>
                </arguments>
            </block>

Now you can manage the footer links using content block by admin panel

0

You can add this line :

<referenceBlock name="footer_links" remove="true"/>

in file default.xml:

For Luma Theme, you can edit from (or in your custom theme):

vendor/magento/theme-frontend-luma/Magento_Theme/layout/default.xml
4
  • I have created a module in which I have added default.xml file – Syed Muneeb Ul Hasan Feb 28 '18 at 11:28
  • Try to add this line in default.xml under your module. don't forget to flush cache and deploy content – Jsparo30 Feb 28 '18 at 11:30
  • I have tried, but it's not working – Syed Muneeb Ul Hasan Feb 28 '18 at 11:31
  • I edited my answer, did you flush cache and content deploy ? – Jsparo30 Feb 28 '18 at 11:32
0

by looking at your code,

<referenceBlock name="privacy-policy-link" remove="true">

you didn't put closing sign in this tag.

It should be like this.

<referenceBlock name="privacy-policy-link" remove="true"/>

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.