1

While customer logged into account it is showing two sign-out from header Kindly check the below default.xml file from my custom theme.

Can you please suggest ? Actually I have used parent theme as Luma.

<?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>
    <referenceContainer name="header.links">
        <block class="Magento\Framework\View\Element\Html\Link\Current" name="helpcenter" before="track-link">
        <arguments>
        <argument name="label" xsi:type="string">Help Center</argument>
        <argument name="path" xsi:type="string">contact</argument>      
        </arguments>
        </block>        
    </referenceContainer>
        <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-container">
            <block class="Magento\Theme\Block\Html\Footer" name="footer" template="html/footer.phtml"/>
        </referenceContainer>
        <referenceBlock name="report.bugs" remove="true"/>
        <move element="copyright" destination="before.body.end"/>
    </body>
</page>

enter image description here

1 Answer 1

0

If you want to hide and show header with respect to customer login/logout

add this in body of file app/design/frontend/vendor/theme/Magento_Theme/layout/default.xml

<referenceBlock name="header.links">
            <block class="vendor\module\Block\Headerlinks" name="history-link" after="my-account-link">
                <arguments>
                    <argument name="sortOrder" xsi:type="number">100</argument>
                </arguments>
            </block>    
        </referenceBlock>

and in file Headerlinks add

    <?php
namespace vendor\module\Block;


class Headerlinks extends \Magento\Framework\View\Element\Template 
{
    protected $customerSession;

    /**
     * Construct
     *
     * @param \Magento\Framework\View\Element\Template\Context $context
     * @param \Magento\Customer\Model\Session $customerSession
     * @param array $data
     */
    public function __construct(
        \Magento\Framework\View\Element\Template\Context $context,
         array $data = [],
         \Magento\Customer\Model\SessionFactory $customerSession
    ) {
        parent::__construct($context, $data);
        $this->customerSession = $customerSession;
    }

    /**
     * Render block HTML
     *
     * @return string
     */
    protected function _toHtml()
    {
        $customer = $this->customerSession->create();
        if ($customer->isLoggedIn()) {
             $link = '<li><a href="' . $this->getUrl('customer/account/') . '" title="Account & Security">Account & Security</a></li>';
             $link .= '<li><a href="' . $this->getUrl('sales/order/history/') . '" title="Purchase History">Purchase History</a></li>';
        return $link;
        }
        return;
    }
}

Your Answer

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

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