0

In the header links, I don't have "customer-welcome" on my website. Below is the screenshot taken from demo site. Please have a look at it.

enter image description here

How can display the customer welcome on my website?

Below is the code I'm having in header.phtml:

<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */

// @codingStandardsIgnoreFile

/**
 * @var \Magento\Theme\Block\Html\Header $block
 */
$welcomeMessage = $block->getWelcome();
?>
<?php switch ($block->getShowPart()):
    case 'welcome': ?>
        <li class="greet welcome" data-bind="scope: 'customer'">
            <!-- ko if: customer().fullname  -->
            <span class="logged-in" data-bind="text: new String('<?= $block->escapeHtml(__('Welcome, %1!', '%1')) ?>').replace('%1', customer().fullname)">
            </span>
            <!-- /ko -->
            <!-- ko ifnot: customer().fullname  -->
            <span class="not-logged-in" data-bind='html:"<?= $block->escapeHtml($welcomeMessage) ?>"'></span>
            <?= $block->getBlockHtml('header.additional') ?>
            <!-- /ko -->
        </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': ?>
        <?= $block->getChildHtml() ?>
    <?php break; ?>

<?php endswitch; ?>

enter image description here

default.xml:

<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="3columns" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
   <update handle="default_head_blocks" />
   <body>
      <!--<referenceBlock name="register-link" remove="true"/>

      <referenceBlock name="header.panel.wrapper" remove="true"/>-->
       <referenceBlock name="my-account-link" remove="true"/>
       <!-- <referenceBlock name="authorization-link" remove="true" />-->
         <referenceBlock name="company.link" remove="true" />


      <!--<referenceBlock name="header-wrapper" remove="true" />-->
      <referenceBlock name="navigation.sections" remove="true" />
      <move element="logo" destination="mycustom3.div" before="-" />
       <move element="header.panel.wrapper" destination="mycustom3.div" after="logo" />
      <move element="catalog.topnav" destination="mycustom3.div" after="header.panel.wrapper" />
      <move element="top.search" destination="mycustom4.div" before="-" />
      <move element="top.links" destination="mycustom4.div" after="top.search" />
      <!--<move element="header-wrapper" destination="mycustom4.div" after="top.search" />-->
      <move element="minicart" destination="mycustom4.div" after="header-wrapper" />
      <move element="mycustom4.div" destination="mycustom3.div" after="catalog.topnav" />

      <referenceContainer name="header.container">
         <container name="mycustom3.div" htmlTag="div" htmlClass="header" />
         <container name="mycustom4.div" htmlTag="div" htmlClass="search-outer" />
      </referenceContainer>







      <referenceContainer name="footer-container" htmlClass="site_footer_wrap scheme_dark">
         <container name="footer" as="footer" label="Page Footer" htmlTag="div">
            <block class="Magento\Theme\Block\Html\Footer" name="butterflyfooter" template="Magento_Theme::html/footer.phtml" />
            <block class="Magento\Theme\Block\Html\Footer" name="copyright" template="Magento_Theme::html/copyright.phtml" />
            <referenceBlock name="store_switcher" remove="true" />
            <referenceBlock name="footer_links" remove="true" />
            <referenceBlock name="report.bugs" remove="true" />
         </container>
      </referenceContainer>


   </body>
</page>

Any help will be appreciated!

  • You want to display message here, Right ? drive.google.com/file/d/14PqZoRFCwroVgEJKrN08mzaBgsS0ckWA/… – Kishan Savaliya Oct 21 at 10:37
  • Kindly share the header.phtml file of your theme. – Sumit Oct 21 at 10:38
  • @KishanSavaliya, After the greeting message, I want to display it. Please refer the attached image at question – Siva Oct 21 at 10:40
  • @Sumit, I have included the header.phtml code in question – Siva Oct 21 at 10:44
  • 1
    Yes, Now I got what you are saying. Give me few mins, I'll let you know. – Kishan Savaliya Oct 21 at 15:04
1

You can update your default.xml with below code

<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="3columns" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
   <update handle="default_head_blocks" />
   <body>
      <!--<referenceBlock name="register-link" remove="true"/>
      <referenceBlock name="header.panel.wrapper" remove="true"/>-->
       <referenceBlock name="my-account-link" remove="true"/>
       <!-- <referenceBlock name="authorization-link" remove="true" />-->
         <referenceBlock name="company.link" remove="true" />
      <!--<referenceBlock name="header-wrapper" remove="true" />-->
      <referenceBlock name="navigation.sections" remove="true" />
      <move element="logo" destination="mycustom3.div" before="-" />
       <move element="header.panel.wrapper" destination="mycustom3.div" after="logo" />
      <move element="catalog.topnav" destination="mycustom3.div" after="header.panel.wrapper" />
      <move element="top.search" destination="mycustom4.div" before="-" />
      <move element="header.links" destination="mycustom4.div" after="top.search" />
      <!--<move element="header-wrapper" destination="mycustom4.div" after="top.search" />-->
      <move element="minicart" destination="mycustom4.div" after="header-wrapper" />
      <move element="mycustom4.div" destination="mycustom3.div" after="catalog.topnav" />

      <referenceContainer name="header.container">
         <container name="mycustom3.div" htmlTag="div" htmlClass="header" />
         <container name="mycustom4.div" htmlTag="div" htmlClass="search-outer" />
      </referenceContainer>

      <referenceContainer name="footer-container" htmlClass="site_footer_wrap scheme_dark">
         <container name="footer" as="footer" label="Page Footer" htmlTag="div">
            <block class="Magento\Theme\Block\Html\Footer" name="butterflyfooter" template="Magento_Theme::html/footer.phtml" />
            <block class="Magento\Theme\Block\Html\Footer" name="copyright" template="Magento_Theme::html/copyright.phtml" />
            <referenceBlock name="store_switcher" remove="true" />
            <referenceBlock name="footer_links" remove="true" />
            <referenceBlock name="report.bugs" remove="true" />
         </container>
      </referenceContainer>

   </body>
</page>

I've changed this line here

<move element="top.links" destination="mycustom4.div" after="top.search" />

Instead of top.links you need to move header.links there like...

<move element="header.links" destination="mycustom4.div" after="top.search" />

After adding this please add below line in your CSS

.customer-welcome .action.switch { color: #111 !important; }

Now please run below commands in your CLI

php bin/magento setup:upgrade
php bin/magento cache:clean
php bin/magento cache:flush

That's it. Then you need to make some CSS changes there and it will work as per your requirements.

Hope this will help you!

  • Is above solution works for you @Siva ? – Kishan Savaliya Oct 22 at 5:51
  • 1
    Yes, I have just updated your code to my default.xml and see the customer menu is displaying when I make some css changes. Still working and let you know if I have any queries. Thanks!! – Siva Oct 22 at 5:59
  • 1
    Approved. Thanks. I have a query, can you please check my question magento.stackexchange.com/questions/293114/… like .account css class, is there any specific class name for login? – Siva Oct 22 at 6:47
  • 1
    Okay great!!! :) – Kishan Savaliya Oct 22 at 7:05
  • 1
    You're right. Its my mistake, I have removed the My account link. Now it works great – Siva Oct 22 at 7:53

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.