10

app/design/frontend/Amydus/test/Magento_Theme/layout/default.xml

<?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>
        <referenceContainer name="header.container">            
            <block class="Magento\Framework\View\Element\Html\Myblock" name="header.myblock">
                <arguments>
                    <argument name="css_class" xsi:type="string">header links</argument>
                </arguments>
            </block>
        </referenceContainer>
        <referenceBlock name="top.links">
            <block class="Magento\Framework\View\Element\Template" name="tlink.them" before="-" template="Magento_Theme::html/header.phtml"/>
        </referenceBlock>
        <referenceBlock name="logo">
            <arguments>
                <argument name="logo_img_width" xsi:type="number">148</argument>
                <argument name="logo_img_height" xsi:type="number">43</argument>
            </arguments>
        </referenceBlock>
        <referenceContainer name="footer">
            <block class="Magento\Store\Block\Switcher" name="store_switcher" as="store_switcher" after="footer_links" template="switch/stores.phtml"/>
        </referenceContainer>
        <referenceBlock name="report.bugs" remove="true"/>
        <move element="copyright" destination="before.body.end"/>
    </body>
</page>

app/design/frontend/Amydus/test/Magento_Theme/templates/html/header.phtml

<?php 
    $objectManager = \Magento\Framework\App\ObjectManager::getInstance();
    $custSession = $objectManager->get('Magento\Customer\Model\Session');
?>
<?php switch ($block->getShowPart()):
    case 'welcome': ?>
        <!-- <li class="greet welcome" data-bind="scope: 'customer'">
            <span data-bind="text: customer().fullname ? $t('Welcome, %1!').replace('%1', customer().fullname) : '<?=$block->escapeHtml($welcomeMessage) ?>'"></span>
        </li> -->
        <li><a style="margin: 3px 0 0 8px;" href="#"><span>CALL US AT - 9560740007</span></a></li>
        <li class=" login_seprator"> | </li>
        <li class="easy-return" ><a style="margin: 3px 0 0 8px;" href="#">  <span >EASY RETURNS & EXCHANGE</span></a>
        </li>
        <li class=" login_seprator"> | </li>                        
        <?php if(!$custSession->isLoggedIn()): ?>
            <li class="hi_li"><span class="guest-color">HI GUEST</span></li>
        <?php else: ?>
            <li class="hi_li"><span><?php echo 'Hi '.$custSession->getCustomer()->getName(); ?></span></li>
        <?php endif; ?>
        <li class=" login_seprator"> | </li>
        <li class="first last top-links-a">
            <?php if($custSession->isLoggedIn()): ?>
                <a class="" title="Log Out" href="#">LOG OUT</a>
            <?php else: ?>
                <a class="" title="Log In" href="#">LOGIN</a>
            <?php endif; ?>
        </li> 

        <script type="text/x-magento-init">
        {
            "*": {
                "Magento_Ui/js/core/app": {
                    "components": {
                        "customer": {
                            "component": "Magento_Customer/js/view/customer"
                        }
                    }
                }
            }
        }
        </script>
    <?php break; ?>

    <?php case 'other': ?>
        <?php echo $block->getChildHtml(); ?>
    <?php break; ?>

<?php endswitch; ?>

2 Answers 2

30

If you extended Luma Theme

app/design/frontend/Amydus/test/Magento_Theme/layout/default.xml

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
       <!--  you can easly add New links with following code -->
        <referenceBlock name="header.links">
               <!-- Contact us Link -->
            <block class="Magento\Framework\View\Element\Html\Link" name="contactus.link" after="register-link">
                <arguments>
                    <argument name="label" xsi:type="string" translate="false">Constact Us</argument>
                    <argument name="path" xsi:type="string" translate="false">contact-us</argument>
                </arguments>
            </block>
            <!-- CMS Page Link Link -->
            <block class="Magento\Framework\View\Element\Html\Link" name="aboutus.link" after="contactus.link">
                <arguments>
                    <argument name="label" xsi:type="string" translate="false">about Us</argument>
                    <argument name="path" xsi:type="string" translate="false">about-us</argument>
                </arguments>
            </block>

             <!--  you can easly Remove  links with following code -->
            <referenceBlock name="register-link" remove="true" />           <!--for Create Account Link-->
            <referenceBlock name="authorization-link" remove="true" />      <!--for Sign In Link  -->
            <referenceBlock name="wish-list-link" remove="true" />          <!--for WishList Link-->
            <referenceBlock name="my-account-link" remove="true" />         <!--for My Account Link-->

        </referenceBlock>
    </body>
</page>

If you extended Blank Theme

app/design/frontend/Amydus/test/Magento_Theme/layout/default.xml

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
       <!--  you can easly add New links with following code -->
        <referenceBlock name="top.links">
               <!-- Contact us Link -->
            <block class="Magento\Framework\View\Element\Html\Link" name="contactus.link" after="register-link">
                <arguments>
                    <argument name="label" xsi:type="string" translate="false">Constact Us</argument>
                    <argument name="path" xsi:type="string" translate="false">contact-us</argument>
                </arguments>
            </block>
            <!-- CMS Page Link Link -->
            <block class="Magento\Framework\View\Element\Html\Link" name="aboutus.link" after="contactus.link">
                <arguments>
                    <argument name="label" xsi:type="string" translate="false">about Us</argument>
                    <argument name="path" xsi:type="string" translate="false">about-us</argument>
                </arguments>
            </block>

             <!--  you can easly Remove  links with following code -->
            <referenceBlock name="register-link" remove="true" />           <!--for Create Account Link-->
            <referenceBlock name="authorization-link" remove="true" />      <!--for Sign In Link  -->
            <referenceBlock name="wish-list-link" remove="true" />          <!--for WishList Link-->
            <referenceBlock name="my-account-link" remove="true" />         <!--for My Account Link-->

        </referenceBlock>
    </body>
</page>
3
  • Anyhow in Magento 2.1.3 the register-link disappears when using your solution. Any idea why?
    – Max
    Jan 23, 2017 at 21:56
  • How about moving those links inside the <div class="header content"></div> element, where the logo is? How would you do that? Dec 13, 2017 at 15:02
  • to remove sign in, you have to use "authorization-link-login" Dec 19, 2019 at 5:28
6

You can also use the Magento\Customer\Block\Account\SortLinkInterface block class, which allows you to sort links in the top.links block.

<referenceBlock name="top.links">
<block class="Magento\Customer\Block\Account\SortLinkInterface" name="newsletter_subscription_top_link">
    <arguments>
        <argument name="label" xsi:type="string" translate="true">Newsletter Subscription</argument>
        <argument name="path" xsi:type="string" translate="true">newsletter/manage</argument>
        <argument name="sortOrder" xsi:type="number">10</argument>
    </arguments>
</block>
</referenceBlock>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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