Magento 2.3 display logged in/out message using private contentMagento2 Wrong Customer Data showing after loginHow do you pass more / custom parameters to the customer bind / private data in knockoutHow to add a Customer Attribute in a custom module using declarative schema in Magento 2.3?Magento 2.3 Install failed … Invalid Index using addColumn methodMagento 2.3 add Product scriptMagento 2.3 - Preserving Success message for showMagento 2: Knockout js dynamic content binding issueMagento 2: Knockout js dynamic content binding repeats the same elementMagento 2.3 : Insert data into table using DeclarativeSchemaMagento 2.3, patch PRODSECBUG-2198-2.3-CE-2019Magento 2.3 Rest API: Error message for each cart itemMagento 2.3: How to display price for out of stock bundles

Why couldn't soldiers sight their own weapons without officers' orders?

Tikzcd pullback square issue

How do I explain to a team that the project they will work on for six months will 100% fail?

How to translate this word-play with the word "bargain" into French?

How to identify the wires on the dimmer to convert it to Conventional on/off switch

How can glass marbles naturally occur in a desert?

Replace data between quotes in a file

Can we use other things than single-word verbs in our dialog tags?

Can an SPI slave start a transmission in full-duplex mode?

Acceptable to cut steak before searing?

Why did the RAAF procure the F/A-18 despite being purpose-built for carriers?

How to write "upright" integrals with automatic sizing

How do I calculate the difference in lens reach between a superzoom compact and a DSLR zoom lens?

During the Space Shuttle Columbia Disaster of 2003, Why Did The Flight Director Say, "Lock the doors."?

Did Apollo leave poop on the moon?

Dropdowns & Chevrons for Right to Left languages

What happen if I gain the control of aura that enchants an opponent's creature? Would the aura stay attached?

Can a character who casts Shapechange and turns into a spellcaster use innate spellcasting to cast spells with a long casting time?

How to say "fit" in Latin?

Is it really ~648.69 km/s delta-v to "land" on the surface of the Sun?

A question about 'reptile and volatiles' to describe creatures

How would I as a DM create a smart phone-like spell/device my players could use?

How to display a duet in lyrics?

Is refreshing multiple times a test case for web applications?



Magento 2.3 display logged in/out message using private content


Magento2 Wrong Customer Data showing after loginHow do you pass more / custom parameters to the customer bind / private data in knockoutHow to add a Customer Attribute in a custom module using declarative schema in Magento 2.3?Magento 2.3 Install failed … Invalid Index using addColumn methodMagento 2.3 add Product scriptMagento 2.3 - Preserving Success message for showMagento 2: Knockout js dynamic content binding issueMagento 2: Knockout js dynamic content binding repeats the same elementMagento 2.3 : Insert data into table using DeclarativeSchemaMagento 2.3, patch PRODSECBUG-2198-2.3-CE-2019Magento 2.3 Rest API: Error message for each cart itemMagento 2.3: How to display price for out of stock bundles






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








1















Does anyone have an example on how to display a logged in vs logged out message on frontend to customer that's not affected by cache without using the cache=false tag and hole punching the whole page



I'm assuming using knockout / section / customerData / private content somehow.



I've read a lot of tutorials and responses like this https://magento.stackexchange.com/a/261067/70343



But just looking for an example on how to do this










share|improve this question


























  • Although the ans provided by me on the link that you shared is definitely sufficient to perform the needed. But if you are still unable to do so I may suggest having a look at default coding, look how magento shows Customer name in top header only for logged in customer, hope that may help you.

    – Narendra Vyas
    Jul 30 at 0:01

















1















Does anyone have an example on how to display a logged in vs logged out message on frontend to customer that's not affected by cache without using the cache=false tag and hole punching the whole page



I'm assuming using knockout / section / customerData / private content somehow.



I've read a lot of tutorials and responses like this https://magento.stackexchange.com/a/261067/70343



But just looking for an example on how to do this










share|improve this question


























  • Although the ans provided by me on the link that you shared is definitely sufficient to perform the needed. But if you are still unable to do so I may suggest having a look at default coding, look how magento shows Customer name in top header only for logged in customer, hope that may help you.

    – Narendra Vyas
    Jul 30 at 0:01













1












1








1








Does anyone have an example on how to display a logged in vs logged out message on frontend to customer that's not affected by cache without using the cache=false tag and hole punching the whole page



I'm assuming using knockout / section / customerData / private content somehow.



I've read a lot of tutorials and responses like this https://magento.stackexchange.com/a/261067/70343



But just looking for an example on how to do this










share|improve this question
















Does anyone have an example on how to display a logged in vs logged out message on frontend to customer that's not affected by cache without using the cache=false tag and hole punching the whole page



I'm assuming using knockout / section / customerData / private content somehow.



I've read a lot of tutorials and responses like this https://magento.stackexchange.com/a/261067/70343



But just looking for an example on how to do this







magento2.3 knockout customer-data






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jul 30 at 8:37







Dominic Xigen

















asked Jul 29 at 23:23









Dominic XigenDominic Xigen

3,2111 gold badge5 silver badges18 bronze badges




3,2111 gold badge5 silver badges18 bronze badges















  • Although the ans provided by me on the link that you shared is definitely sufficient to perform the needed. But if you are still unable to do so I may suggest having a look at default coding, look how magento shows Customer name in top header only for logged in customer, hope that may help you.

    – Narendra Vyas
    Jul 30 at 0:01

















  • Although the ans provided by me on the link that you shared is definitely sufficient to perform the needed. But if you are still unable to do so I may suggest having a look at default coding, look how magento shows Customer name in top header only for logged in customer, hope that may help you.

    – Narendra Vyas
    Jul 30 at 0:01
















Although the ans provided by me on the link that you shared is definitely sufficient to perform the needed. But if you are still unable to do so I may suggest having a look at default coding, look how magento shows Customer name in top header only for logged in customer, hope that may help you.

– Narendra Vyas
Jul 30 at 0:01





Although the ans provided by me on the link that you shared is definitely sufficient to perform the needed. But if you are still unable to do so I may suggest having a look at default coding, look how magento shows Customer name in top header only for logged in customer, hope that may help you.

– Narendra Vyas
Jul 30 at 0:01










2 Answers
2






active

oldest

votes


















1














You can just dive in Magento core coding it-self in order to have a better understanding.



Magento shows customer name for logged in customers only and not for guest customers, you may have a look at code responsible for that here:



vendor/magento/module-theme/view/frontend/templates/html/header.phtml


A already created customer section is used in this file have a look here:



<script type="text/x-magento-init">

"*":
"Magento_Ui/js/core/app":
"components":
"customer":
"component": "Magento_Customer/js/view/customer"





</script>


Then binded by knockout as :



data-bind="scope: 'customer'"


Accessed as :



customer().fullname


Here a pre existing section is been utilized if needed you may create your custom section as well, depending on your need.



Hope that helps.






share|improve this answer
































    1














    Narendra certainly pointed me in the right direction.



    Here is a complete example.



    https://github.com/DominicWatts/CustomerLogin/blob/master/view/frontend/templates/index/index.phtml



    <div class="greet welcome" data-bind="scope: 'customer'">
    <!-- ko if: customer().fullname -->
    <span class="logged-in"
    data-bind="text: new String('<?= $block->escapeHtml(__('Welcome back %1', '%1')) ?>').replace('%1', customer().firstname)">
    </span>
    <!-- /ko -->
    <!-- ko ifnot: customer().fullname -->
    <span class="not-logged-in"
    data-bind='html:"<?= $block->escapeHtml(__("Please <a href='%1'>login</a>", $block->getUrl('customer/account/login'))) ?>"'>
    </span>
    <!-- /ko -->
    </div>
    <script type="text/x-magento-init">

    "*":
    "Magento_Ui/js/core/app":
    "components":
    "customer":
    "component": "Magento_Customer/js/view/customer"





    </script>





    share|improve this answer



























      Your Answer








      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "479"
      ;
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function()
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled)
      StackExchange.using("snippets", function()
      createEditor();
      );

      else
      createEditor();

      );

      function createEditor()
      StackExchange.prepareEditor(
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: false,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: null,
      bindNavPrevention: true,
      postfix: "",
      imageUploader:
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      ,
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );













      draft saved

      draft discarded


















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f283725%2fmagento-2-3-display-logged-in-out-message-using-private-content%23new-answer', 'question_page');

      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      1














      You can just dive in Magento core coding it-self in order to have a better understanding.



      Magento shows customer name for logged in customers only and not for guest customers, you may have a look at code responsible for that here:



      vendor/magento/module-theme/view/frontend/templates/html/header.phtml


      A already created customer section is used in this file have a look here:



      <script type="text/x-magento-init">

      "*":
      "Magento_Ui/js/core/app":
      "components":
      "customer":
      "component": "Magento_Customer/js/view/customer"





      </script>


      Then binded by knockout as :



      data-bind="scope: 'customer'"


      Accessed as :



      customer().fullname


      Here a pre existing section is been utilized if needed you may create your custom section as well, depending on your need.



      Hope that helps.






      share|improve this answer





























        1














        You can just dive in Magento core coding it-self in order to have a better understanding.



        Magento shows customer name for logged in customers only and not for guest customers, you may have a look at code responsible for that here:



        vendor/magento/module-theme/view/frontend/templates/html/header.phtml


        A already created customer section is used in this file have a look here:



        <script type="text/x-magento-init">

        "*":
        "Magento_Ui/js/core/app":
        "components":
        "customer":
        "component": "Magento_Customer/js/view/customer"





        </script>


        Then binded by knockout as :



        data-bind="scope: 'customer'"


        Accessed as :



        customer().fullname


        Here a pre existing section is been utilized if needed you may create your custom section as well, depending on your need.



        Hope that helps.






        share|improve this answer



























          1












          1








          1







          You can just dive in Magento core coding it-self in order to have a better understanding.



          Magento shows customer name for logged in customers only and not for guest customers, you may have a look at code responsible for that here:



          vendor/magento/module-theme/view/frontend/templates/html/header.phtml


          A already created customer section is used in this file have a look here:



          <script type="text/x-magento-init">

          "*":
          "Magento_Ui/js/core/app":
          "components":
          "customer":
          "component": "Magento_Customer/js/view/customer"





          </script>


          Then binded by knockout as :



          data-bind="scope: 'customer'"


          Accessed as :



          customer().fullname


          Here a pre existing section is been utilized if needed you may create your custom section as well, depending on your need.



          Hope that helps.






          share|improve this answer













          You can just dive in Magento core coding it-self in order to have a better understanding.



          Magento shows customer name for logged in customers only and not for guest customers, you may have a look at code responsible for that here:



          vendor/magento/module-theme/view/frontend/templates/html/header.phtml


          A already created customer section is used in this file have a look here:



          <script type="text/x-magento-init">

          "*":
          "Magento_Ui/js/core/app":
          "components":
          "customer":
          "component": "Magento_Customer/js/view/customer"





          </script>


          Then binded by knockout as :



          data-bind="scope: 'customer'"


          Accessed as :



          customer().fullname


          Here a pre existing section is been utilized if needed you may create your custom section as well, depending on your need.



          Hope that helps.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Jul 30 at 0:20









          Narendra VyasNarendra Vyas

          6931 silver badge13 bronze badges




          6931 silver badge13 bronze badges


























              1














              Narendra certainly pointed me in the right direction.



              Here is a complete example.



              https://github.com/DominicWatts/CustomerLogin/blob/master/view/frontend/templates/index/index.phtml



              <div class="greet welcome" data-bind="scope: 'customer'">
              <!-- ko if: customer().fullname -->
              <span class="logged-in"
              data-bind="text: new String('<?= $block->escapeHtml(__('Welcome back %1', '%1')) ?>').replace('%1', customer().firstname)">
              </span>
              <!-- /ko -->
              <!-- ko ifnot: customer().fullname -->
              <span class="not-logged-in"
              data-bind='html:"<?= $block->escapeHtml(__("Please <a href='%1'>login</a>", $block->getUrl('customer/account/login'))) ?>"'>
              </span>
              <!-- /ko -->
              </div>
              <script type="text/x-magento-init">

              "*":
              "Magento_Ui/js/core/app":
              "components":
              "customer":
              "component": "Magento_Customer/js/view/customer"





              </script>





              share|improve this answer





























                1














                Narendra certainly pointed me in the right direction.



                Here is a complete example.



                https://github.com/DominicWatts/CustomerLogin/blob/master/view/frontend/templates/index/index.phtml



                <div class="greet welcome" data-bind="scope: 'customer'">
                <!-- ko if: customer().fullname -->
                <span class="logged-in"
                data-bind="text: new String('<?= $block->escapeHtml(__('Welcome back %1', '%1')) ?>').replace('%1', customer().firstname)">
                </span>
                <!-- /ko -->
                <!-- ko ifnot: customer().fullname -->
                <span class="not-logged-in"
                data-bind='html:"<?= $block->escapeHtml(__("Please <a href='%1'>login</a>", $block->getUrl('customer/account/login'))) ?>"'>
                </span>
                <!-- /ko -->
                </div>
                <script type="text/x-magento-init">

                "*":
                "Magento_Ui/js/core/app":
                "components":
                "customer":
                "component": "Magento_Customer/js/view/customer"





                </script>





                share|improve this answer



























                  1












                  1








                  1







                  Narendra certainly pointed me in the right direction.



                  Here is a complete example.



                  https://github.com/DominicWatts/CustomerLogin/blob/master/view/frontend/templates/index/index.phtml



                  <div class="greet welcome" data-bind="scope: 'customer'">
                  <!-- ko if: customer().fullname -->
                  <span class="logged-in"
                  data-bind="text: new String('<?= $block->escapeHtml(__('Welcome back %1', '%1')) ?>').replace('%1', customer().firstname)">
                  </span>
                  <!-- /ko -->
                  <!-- ko ifnot: customer().fullname -->
                  <span class="not-logged-in"
                  data-bind='html:"<?= $block->escapeHtml(__("Please <a href='%1'>login</a>", $block->getUrl('customer/account/login'))) ?>"'>
                  </span>
                  <!-- /ko -->
                  </div>
                  <script type="text/x-magento-init">

                  "*":
                  "Magento_Ui/js/core/app":
                  "components":
                  "customer":
                  "component": "Magento_Customer/js/view/customer"





                  </script>





                  share|improve this answer













                  Narendra certainly pointed me in the right direction.



                  Here is a complete example.



                  https://github.com/DominicWatts/CustomerLogin/blob/master/view/frontend/templates/index/index.phtml



                  <div class="greet welcome" data-bind="scope: 'customer'">
                  <!-- ko if: customer().fullname -->
                  <span class="logged-in"
                  data-bind="text: new String('<?= $block->escapeHtml(__('Welcome back %1', '%1')) ?>').replace('%1', customer().firstname)">
                  </span>
                  <!-- /ko -->
                  <!-- ko ifnot: customer().fullname -->
                  <span class="not-logged-in"
                  data-bind='html:"<?= $block->escapeHtml(__("Please <a href='%1'>login</a>", $block->getUrl('customer/account/login'))) ?>"'>
                  </span>
                  <!-- /ko -->
                  </div>
                  <script type="text/x-magento-init">

                  "*":
                  "Magento_Ui/js/core/app":
                  "components":
                  "customer":
                  "component": "Magento_Customer/js/view/customer"





                  </script>






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Jul 30 at 12:40









                  Dominic XigenDominic Xigen

                  3,2111 gold badge5 silver badges18 bronze badges




                  3,2111 gold badge5 silver badges18 bronze badges






























                      draft saved

                      draft discarded
















































                      Thanks for contributing an answer to Magento Stack Exchange!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid


                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.

                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f283725%2fmagento-2-3-display-logged-in-out-message-using-private-content%23new-answer', 'question_page');

                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      Category:9 (number) SubcategoriesMedia in category "9 (number)"Navigation menuUpload mediaGND ID: 4485639-8Library of Congress authority ID: sh85091979ReasonatorScholiaStatistics

                      Circuit construction for execution of conditional statements using least significant bitHow are two different registers being used as “control”?How exactly is the stated composite state of the two registers being produced using the $R_zz$ controlled rotations?Efficiently performing controlled rotations in HHLWould this quantum algorithm implementation work?How to prepare a superposed states of odd integers from $1$ to $sqrtN$?Why is this implementation of the order finding algorithm not working?Circuit construction for Hamiltonian simulationHow can I invert the least significant bit of a certain term of a superposed state?Implementing an oracleImplementing a controlled sum operation

                      Magento 2 “No Payment Methods” in Admin New OrderHow to integrate Paypal Express Checkout with the Magento APIMagento 1.5 - Sales > Order > edit order and shipping methods disappearAuto Invoice Check/Money Order Payment methodAdd more simple payment methods?Shipping methods not showingWhat should I do to change payment methods if changing the configuration has no effects?1.9 - No Payment Methods showing upMy Payment Methods not Showing for downloadable/virtual product when checkout?Magento2 API to access internal payment methodHow to call an existing payment methods in the registration form?