:::: MENU ::::
Posts tagged with: top links

Magento 2 add remove footer link

Today we talk about how in magento 2 add remove footer link. This tutorial will include how to add footer link, how to remove footer link and how to add custom link in footer. So first we listed all current link that are available in footer.

Footer Links

Here is all available footer link.

Title Name
Privacy and Cookie Policy privacy-policy-link
Search Terms search-term-popular-link
Contact Us contact-us-link
Advanced Search catalog-search-advanced-link
Orders and Returns sales-guest-form-link

Remove Footer link

Now we will remove a link from footer links. For example we want to remove Privacy and Cookie Policy link from footer. For that we will use his code privacy-policy-link. Just simple use remove block code. First create default.xml in view/frontend/layout

<?xml version="1.0"?>
<!--/**
   * Simple Hello World Module
   *
   * @category    QaisarSatti
   * @package     QaisarSatti_HelloWorld
   * @author      Muhammad Qaisar Satti
   * @Email       [email protected]
   *
   */ -->
    <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"/>
        </body>
    </page>

Same example go for other links too.

Add Footer link

Now we will add the custom link in footer links. For example you want to add footer link title Hello World and there must be unique name helloworld.First create default.xml in view/frontend/layout

<?xml version="1.0"?>
<!--/**
    * Simple Hello World Module
    *
    * @category    QaisarSatti
    * @package     QaisarSatti_HelloWorld
    * @author      Muhammad Qaisar Satti
    * @Email       [email protected]
    *
    */ -->
    <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">
                <block class="Magento\Framework\View\Element\Html\Link\Current" name="helloworld">
                    <arguments>
                        <argument name="label" xsi:type="string">Hello World</argument>
                        <argument name="path" xsi:type="string">helloworld</argument>
                    </arguments>
                </block>
            </referenceBlock>
        </body>
    </page>
Author: Qaisar Satti
Category: Magento 2
Last Modified: July 12, 2018


Magento 2 add custom link top links

Today, we’ll talk about how in Magento 2 add custom link top links.It is very create For any suggestions & question, please feel free to drop a comment.

If you are adding it from theme create default.xml in following path.

app/design/frontend/QaisarSatti/theme/Magento_Theme/layout/default.xml

Or you want it to add from module xml then create default.xml in following path.

app/code/QaisarSatti/view/HelloWorld/frontend/layout/default.xml

Blank Theme top links

Now add the following code, you can add label and url as you required.

<referenceBlock name="top.links">          
          <block class="Magento\Framework\View\Element\Html\Link\Current" name="cart" before="account">
                    <arguments>
                       <argument name="label" xsi:type="string">Cart</argument>
                       <argument name="path" xsi:type="string">checkout/cart</argument>          
                    </arguments>            
          </block>
</referenceBlock>

Luma Theme header links

Now add the following code, you can add label and url as you required.

<referenceBlock name="header.links">          
          <block class="Magento\Framework\View\Element\Html\Link\Current" name="cart" before="account">
                    <arguments>
                       <argument name="label" xsi:type="string">Cart</argument>
                       <argument name="path" xsi:type="string">checkout/cart</argument>          
                    </arguments>            
          </block>
</referenceBlock>
Author: Qaisar Satti
Category: Magento 2
Last Modified: July 12, 2018


Magento 2 remove any link from top links

 

Today we talk about how in Magento 2 remove any link from top links. For removing the top-link you must know name of the link to remove link. Register-link is for register-link link.

Here is  Name list of top-link.



register-link                Create Account Link

authorization-link       Sign In Link

 

wish-list-link              WishList Link

 

my-account-link        My Account Link

 

Add below code in your default.xml remove the link. For example you want to remove the Create Account Link for that you have to add below xml.

<referenceBlock name="top.links">
        <referenceBlock name="register-link" remove="true" />          
 </referenceBlock>

 

Same goes for other link too.

Author: Qaisar Satti
Category: Magento 2
Last Modified: July 12, 2018