Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
litespeed_wiki:cache:litemage:troubleshooting:logged-in-logout_banner_disappear [2017/05/04 13:24]
Jackson Zhang
litespeed_wiki:cache:litemage:troubleshooting:logged-in-logout_banner_disappear [2017/05/04 20:54] (current)
Michael Alegre [Issue 3: The Case of The Disappearing Banner]
Line 1: Line 1:
-===== A LiteMage ​troubleshooting case study: "​Loggin/​logout"​ issue, "​compare"​ issue and "​banner"​ disappears issue ===== +====== A LiteMage ​Troubleshooting Showcase ======
-In this troubleshooting case study, we will show you multiple issues(including "​Loggin/​logout"​ issue, "​compare"​ issue and "​banner"​ disappears issue), troubleshooting processes and recommended solutions to fix them. +
  
-At Home pagethere is one section ​at the top which says **"​Welcome Login or Create an Account"​**. With LiteMage enabled, If user is logged in, it shows "​Welcome Sam! Login or Create an Account"​ While it should show "​Welcome,​ Sam Logout!"​. Some time, LiteMage caches " Welcome, hole login or create account " if no one is logged in or it caches "​Welcomehole Logout"​ if a user is logged in. In that casefor other user which just opened ​the home page, it shows, "​Welcome,​ Logout"​.+In this troubleshooting showcasewe will be looking ​at a case where a Magento site was having ​login/logout issuescomparison issuesand disappearing banner issues as well as the troubleshooting processes and recommended solutions to fix them
  
-The user uses theme SM Market. ​It looks like a template problem. Basically, we need to punch a hole for that piece of info together ​with the login buttonwith welcome tag.+It is assumed ​that you are already familiar ​with Magento Layoutsblocks, and templates as well as how to make proper changes to them. You can find out more from the [[http://​devdocs.magento.com/​guides/​m1x/​magefordev/​mage-for-dev-4.html|Magento 1.x Developer Reference]].
  
-Global PHP variables can not be initialized in header.phtml and social.phtml,​ update those two files: +==== Issue 1Login/Logout ====
-  ​/home/​user1/​public_html/​domain1.com/​app/​design/​frontend/​sm_market/​default/​template]#​ vi page/​html/​header.phtml +
-  /​home/​user1/​public_html/​domain1.com/​app/​design/​frontend/​sm_market/​default/​template]#​ vi page/​html/​social.phtml  +
-by adding the following to the top of the template(please be aware that that Varable name could be different to the example):+
  
-  if (empty($var_yttheme)) { +On the home page, there is a "​Welcome/Login/Create an Account"​ section at the topIf a user logs in, we expect ​to see something like ''​Welcome,​ Sam! Logout''​. With LiteMage installed, we were instead seeing ''​Welcome Sam! Login or Create an Account.''​ In this case, LiteMage cached ''​Welcome,​ <​punched_hole>​! Login or Create an Account''​ for a logged out user and served that to the logged in user.
-        include (dirname(dirname(__FILE__)).'​/sm/yt_prepar.php'​);​ +
-  } +
-   +
-according ​to [[litespeed_wiki:​cache:​litemage:​troubleshooting:​uninitialized-php-vars-injected-block|this wiki]].+
  
-After initialization problem resolvedwe need to punch big hole instead of small one. In MagentoAdmin LiteMage configenter "​header" ​in Customized Block Names for "​toplinks"​ Tag+This issue was also happening in reverse! LiteMage would instead cache ''​Welcome<​punched_hole>​! Logout''​ for logged in userserving ''​Welcome,​ ! Logout''​ to non-logged ​in users.
  
 +Looking further, we see that the user uses the SM Market theme. It looks like a template problem.
  
-Put "​compare"​ in Additional Purge Tags for "​toplinks"​ Blocks.+We need to punch a hole for that piece of info along with the login button and welcome tag(**[[litespeed_wiki:​cache:​litemage:​troubleshooting:​checking-hole-punching|How to check hole punching]]**)
  
-The above solutions fixed Loggin/​logout user showing wrong info issue. But due to the changesthe banner disappears from homepage.+Since LiteMage processes these ESI blocks in small chunkssome global PHP variables initialized in header.phtml and social.phtml were not available in these chunks. These two files needed to be updated to initialize them: 
  
-After further investigation,​ we found out the header template includes logic to check if it'​s ​frontend ​or notIf it is frontend, then it show bannerSo we cannot simply punch a big hole for the header.+<​code>​ 
 +/​home/​user1/​public_html/​domain1.com/​app/​design/​frontend/​sm_market/​default/​template]#​ vi page/​html/​header.phtml 
 +/​home/​user1/​public_html/​domain1.com/​app/​design/​frontend/​sm_market/​default/​template]#​ vi page/​html/​social.phtml 
 +</​code>​ 
 +  
 +The following was added to the top of the two templates
  
-The solution is go back to fix the login linksWe basically needs to single out the logic and put it in its own block so we can hole punch it as a private block. The rest can be publicly cached.+<​code>​ 
 +if (empty($var_yttheme)) { 
 +    include (dirname(dirname(__FILE__)).'/​sm/​yt_prepar.php'​);​ 
 +
 +</​code>​
  
-Copy original files as .bak.+according to our **[[litespeed_wiki:​cache:​litemage:​troubleshooting:​uninitialized-php-vars-injected-block|Uninitialized PHP Vars In Injected Blocks]]** page.
  
-Header style selection is “header4” 
  
-Inside [app/​design/​frontend/​sm_market/​default/​template/​page/​html]vi header4.phtml,​ We can see the logged-in link is mixed in the header template. We need to take that logic out and put in its own block and template, so we can punch a hole for that block.+==== Issue 2: Punching A Bigger Hole While Still Purging Private Sections ====
  
-  ​<div class="​yt-header-top">​+Now that the initialization problem is solved, we need to punch a big hole instead of small one. Logging into the Magento Admin and entering LiteMage config, we add "​header"​ in **Customized Block Names for "​toplinks"​ Tag**.  
 + 
 +We also see "​compare"​ in a toplinks block, so we add "​compare"​ to **Additional Purge Tags for "​toplinks"​ Blocks** as well. 
 + 
 +{{ :​litespeed_wiki:​cache:​litemage:​troubleshooting:​litemage-see-minicompare-tag-add-purge.png?​nolink |}} 
 + 
 +For more info on this step, check out **[[litespeed_wiki:​cache:​litemage:​troubleshooting:​logged-in-user-info-shown-to-others|Logged In Usernames/​Cart Items Shown On Other User's Pages]]**. 
 + 
 + 
 +==== Issue 3: The Case of The Disappearing Banner ==== 
 + 
 +At this point we have fixed the login/​logout issue. Great! Except now the banner has disappeared from the homepage. 
 + 
 +After some further investigation,​ we found that the header template included logic to check if it is displaying on a frontend page or not. If it is not a frontend page, then the banner will not display. This stops us from simply punching a big hole for the header, like we did earlier. 
 + 
 +We now needed to go back and "​fix"​ the login links. 
 + 
 +After making a copy of ''​header4.phtml'',​ the header style file, we open it to begin modifying.  
 + 
 +<​code>​ 
 +[app/​design/​frontend/​sm_market/​default/​template/​page/​html]vi header4.phtml 
 +</​code>​ 
 + 
 +Inside we can see the "log in" link mixed into the header template. That logic needs to be taken out and put in its own block/​template so we can both hole punch it as a private block AND keep the rest of the header publicly cached. 
 + 
 +<​code>​ 
 +<div class="​yt-header-top">​
   <div class="​container">​   <div class="​container">​
-  ​<div class="​row">​ +    ​<div class="​row">​ 
-  <div class="​header-top-1 col-lg-4 col-md-4 col-sm-6 col-xs-12">​ +      <div class="​header-top-1 col-lg-4 col-md-4 col-sm-6 col-xs-12">​ 
-  <div class="​inner">​ +        <div class="​inner">​ 
-  <p class="​welcome-msg"><?​php echo $this->​getChildHtml('​welcome'​) ?> <?php echo $this->​getAdditionalHtml() ?></​p>​ +          <p class="​welcome-msg"><?​php echo $this->​getChildHtml('​welcome'​) ?> <?php echo $this->​getAdditionalHtml() ?></​p>​ 
-  <div class="​login-regis">​ +          <div class="​login-regis">​ 
-                    <?php if(!$this->​helper('​customer'​)->​isLoggedIn() ){ ?> +            <?php if(!$this->​helper('​customer'​)->​isLoggedIn() ){ ?> 
-                        <a title="<?​php echo $this->​__("​Login"​);​ ?>" class="​btn-head"​ href="<?​php echo $this- +            <a title="<?​php echo $this->​__("​Login"​);​ ?>" class="​btn-head"​ href="<?​php echo $this- 
-  >​getUrl('​customer/​account/​login/'​) ?>">​ +               ​>​getUrl('​customer/​account/​login/'​) ?>">​ 
-                            <?php echo $this->​__("​Login"​);​ ?> +               ​<?php echo $this->​__("​Login"​);​ ?> 
-                        </​a>​ +          </​a>​ 
-                        <?php echo $this->​__("​or"​);​ ?> +          <?php echo $this->​__("​or"​);​ ?> 
-                    <?php } else{ ?> +          <?php } else{ ?> 
-                        <a title="<?​php echo $this->​__("​Logout"​);​ ?>" class="​btn-head"​ href="<?​php echo $this- +          <a title="<?​php echo $this->​__("​Logout"​);​ ?>" class="​btn-head"​ href="<?​php echo $this- 
-  >​getUrl('​customer/​account/​logout'​) ?>">​ +             ​>​getUrl('​customer/​account/​logout'​) ?>">​ 
-                            <?php echo $this->​__("​Logout"​);​ ?> +             ​<?php echo $this->​__("​Logout"​);​ ?> 
-                        </​a>​ +        </​a>​ 
-                    <?php } ?> +        <?php } ?> 
-                    <?php +        <?php 
-                    //​if(Mage::​getSingleton('​customer/​session'​)->​isLoggedIn()) +        //​if(Mage::​getSingleton('​customer/​session'​)->​isLoggedIn()) 
-                    if(!$this->​helper('​customer'​)->​isLoggedIn() ){ ?> +        if(!$this->​helper('​customer'​)->​isLoggedIn() ){ ?> 
-                        <a title="<?​php echo $this->​__("​Create an Account"​);​ ?>" class="​btn-head"​ href="<?​php echo  +        <a title="<?​php echo $this->​__("​Create an Account"​);​ ?>" class="​btn-head"​ href="<?​php echo  
-  Mage::​getBaseUrl();​ ?>​customer/​account/​create/">​ +           ​Mage::​getBaseUrl();​ ?>​customer/​account/​create/">​ 
-                        <?php echo $this->​__("​Create an Account"​);​ ?></a+           ​<?php echo $this->​__("​Create an Account"​);​ ?></​a>​ 
-                    <?php } ?> +        <?php } ?> 
-                </​div>​ +      </​div>​
-            </div+
-        ​</​div>​ +
-        <div class="​header-top-2 col-lg-4 col-md-4 col-sm-6 col-xs-12">​ +
-            <?php if($this->​getLayout()->​createBlock('​cms/​block'​)->​setBlockId('​v4-call-us'​)->​toHtml()) { ?> +
-                <?php echo $this->​getLayout()->​createBlock('​cms/​block'​)->​setBlockId('​v4-call-us'​)->​toHtml();​ ?> +
-            ​<?php } ?> +
-        </​div>​ +
-        <div class="​header-top-3 col-lg-4 col-md-4 col-sm-6 col-xs-12">​ +
-            <div class="​inner">​ +
-                <div class="​head-quicklink">​ +
-                    <?php echo $this->​getChildHtml('​topLinks'​);?>​ +
-                </​div>​ +
-            </​div>​ +
-        ​</​div>​+
     </​div>​     </​div>​
   </​div>​   </​div>​
 +  <div class="​header-top-2 col-lg-4 col-md-4 col-sm-6 col-xs-12">​
 +    <?php if($this->​getLayout()->​createBlock('​cms/​block'​)->​setBlockId('​v4-call-us'​)->​toHtml()) { ?>
 +    <?php echo $this->​getLayout()->​createBlock('​cms/​block'​)->​setBlockId('​v4-call-us'​)->​toHtml();​ ?>
 +    <?php } ?>
   </​div>​   </​div>​
 +  <div class="​header-top-3 col-lg-4 col-md-4 col-sm-6 col-xs-12">​
 +    <div class="​inner">​
 +      <div class="​head-quicklink">​
 +        <?php echo $this->​getChildHtml('​topLinks'​);?>​
 +      </​div>​
 +    </​div>​
 +  </​div>​
 +</​div>​
 +</​div>​
 +</​div>​
 +</​code>​
  
-We call the new block “welcomelogin.+We copy the code inside ''<​div class="​login-regis">''​ and move it int our new welcomelogin.phtml file.
  
-Modify layout file [app/​design/​frontend/​sm_market/​default/​layout]# vi page.xml+<​code>​ 
 +[app/​design/​frontend/​sm_market/​default/​template/​page/​html]# vi welcomelogin.phtml
  
-Insider header block we add our new “welcomelogin” block:+<?php if(!$this->​helper('​customer'​)->​isLoggedIn() ){ ?> 
 +<a title="<?​php echo $this->​__("​Login"​);​ ?>" class="​btn-head"​ href="<?​php echo $this- 
 +   >​getUrl('​customer/​account/​login/'​) ?>">​ 
 +   <?​php echo $this->​__("​Login"​);​ ?> 
 +</​a>​ 
 +<?php echo $this->​__("​or"​);​ ?> 
 +<?php } else{ ?> 
 +<a title="<?​php echo $this->​__("​Logout"​);​ ?>" class="​btn-head"​ href="<?​php echo $this- 
 +   >​getUrl('​customer/​account/​logout'​) ?>">​ 
 +   <?​php echo $this->​__("​Logout"​);​ ?> 
 +</​a>​ 
 +<?php } ?> 
 +<?php 
 +//if(Mage::​getSingleton('​customer/​session'​)->​isLoggedIn()) 
 +if(!$this->​helper('​customer'​)->​isLoggedIn() ){ ?> 
 +<a title="<?​php echo $this->​__("​Create an Account"​);​ ?>" class="​btn-head"​ href="<?​php echo  
 +   ​Mage::​getBaseUrl();​ ?>​customer/​account/​create/">​ 
 +   <?​php echo $this->​__("​Create an Account"​);​ ?></​a>​ 
 +<?php } ?> 
 +</​code>​
  
-  <block type="​page/​html_header"​ name="header" as="​header">​ +We now add our new “welcomelogin” ​block in the header ​block...
-  …. +
-  …After welcome block +
-  <block type="​core/​template"​ name="​welcomelogin"​ as="​welcomelogin"​ template="​page/​html/​welcomelogin.phtml"/>​+
  
-Move the logic out of the header4.phtml and put in our new welcomelogin.phtml +<​code>​ 
-  [app/​design/​frontend/​sm_market/​default/​template/​page/​html]# vi welcomelogin.phtml+[app/​design/​frontend/​sm_market/​default/​layout]# vi page.xml
  
-                    ​<?php if(!$this->​helper('​customer'​)->​isLoggedIn() ){ ?> +<block type="page/​html_header" ​name="header" ​as="header">​ 
-                        <a title="<?php echo $this->​__("​Login"​);​ ?>" ​class="btn-head" ​href="<?php echo $this- +…. 
-  >​getUrl('​customer/​account/​login/'​) ?>">​ +…. After welcome block 
-                            <?​php echo $this->​__("​Login"​);​ ?> +<block type="core/​template" ​name="welcomelogin" ​as="welcomelogin" ​template="page/html/welcomelogin.phtml"/>​ 
-                        </​a>​ +</code
-                        <?php echo $this->​__("or"); ?> + 
-                    <?php } else{ ?> +...and update the header4.phtml file to reference the new "welcomelogin" ​block where the "log in" ​logic used to be
-                        <a title="<?php echo $this->​__("Logout"​);​ ?>" class="btn-head" ​href="<?php echo $this- + 
-  >​getUrl('​customer/account/logout'​) ?>"+<code
-                            <?php echo $this->​__("​Logout"​);​ ?> +<div class="​yt-header-top">​
-                        </a+
-                    <?php } ?> +
-                    <?php +
-                    ​//​if(Mage::​getSingleton('​customer/​session'​)->isLoggedIn()) +
-                    ​if(!$this->​helper('​customer'​)->​isLoggedIn() ){ ?> +
-                        <a title="<?php echo $this->​__("Create an Account"); ?>" ​class="​btn-head"​ href="<?​php echo  +
-  Mage::​getBaseUrl();​ ?>​customer/​account/​create/">​ +
-                        <?​php echo $this->​__("​Create an Account"​);​ ?></​a>​ +
-                    <?php } ?+
-  ​Update header4.phtml,​ referensing the new welcomelogin block +
-  ​<div class="​yt-header-top">​+
   <div class="​container">​   <div class="​container">​
-  ​<div class="​row">​ +    ​<div class="​row">​ 
-  <div class="​header-top-1 col-lg-4 col-md-4 col-sm-6 col-xs-12">​ +      <div class="​header-top-1 col-lg-4 col-md-4 col-sm-6 col-xs-12">​ 
-  <div class="​inner">​ +        <div class="​inner">​ 
-  <p class="​welcome-msg"><?​php echo $this->​getChildHtml('​welcome'​) ?> <?php echo $this->​getAdditionalHtml() ?></​p>​ +          <p class="​welcome-msg"><?​php echo $this->​getChildHtml('​welcome'​) ?> <?php echo $this->​getAdditionalHtml() ?></​p>​ 
-  <div class="​login-regis">​ +          <div class="​login-regis">​ 
-  <?php echo $this->​getChildHtml('​welcomelogin'​);​ ?> +            <?php echo $this->​getChildHtml('​welcomelogin'​);​ ?> 
-  </​div>​ +          </​div>​ 
-  </​div>​ +        </​div>​ 
-  </​div>​ +      </​div>​ 
-  <div class="​header-top-2 col-lg-4 col-md-4 col-sm-6 col-xs-12">​ +      <div class="​header-top-2 col-lg-4 col-md-4 col-sm-6 col-xs-12">​ 
-  <?php if($this->​getLayout()->​createBlock('​cms/​block'​)->​setBlockId('​v4-call-us'​)->​toHtml()) { ?> +        <?php if($this->​getLayout()->​createBlock('​cms/​block'​)->​setBlockId('​v4-call-us'​)->​toHtml()) { ?> 
-  <?php echo $this->​getLayout()->​createBlock('​cms/​block'​)->​setBlockId('​v4-call-us'​)->​toHtml();​ ?>+        <?php echo $this->​getLayout()->​createBlock('​cms/​block'​)->​setBlockId('​v4-call-us'​)->​toHtml();​ ?>
         <?php } ?>         <?php } ?>
-    ​</​div>​ +      ​</​div>​ 
-    <div class="​header-top-3 col-lg-4 col-md-4 col-sm-6 col-xs-12">​+      <div class="​header-top-3 col-lg-4 col-md-4 col-sm-6 col-xs-12">​
         <div class="​inner">​         <div class="​inner">​
-            ​<div class="​head-quicklink">​ +          ​<div class="​head-quicklink">​ 
-                <?php echo $this->​getChildHtml('​topLinks'​);?>​ +            <?php echo $this->​getChildHtml('​topLinks'​);?>​ 
-            </​div>​+          </​div>​
         </​div>​         </​div>​
 +      </​div>​
     </​div>​     </​div>​
   </​div>​   </​div>​
-  ​</​div>​ +</​div>​ 
-  </div>+</code> 
 + 
 +Finally we go back to our LiteMage Configuration in the Magento Admin Panel and add “welcomelogin” to **Customized Block Names for "​welcome"​ Tag**. 
 + 
 +Voila! The banner is back and LiteMage is operating at 100%.
  
-Go to Magento admin panel LiteMage ​Configuration,​ add “welcomelogin” ​to Customized Block Names for "​welcome"​ Tag. Banner shows up.+==== Need Help? ==== 
 +Are you running into complicated ​LiteMage ​issues? Does the above showcase seem too overwhelming ​to tackle on your own?
  
-In real-time, situation may be more complicated than the above showcase, you might want to engage ​our experienced LiteMage Support ​Engineer/​LiteMage ​Developer ​for professional ​investigation and fix them, It is fully refundable if we can not make your litemage work. Please check [[litespeed_wiki:​cache:​litemage:​support_tiers|our support ​here]].+In cases such as these we recommend engaging with our experienced LiteMage Support ​Engineers/​LiteMage ​Developers ​for a formal ​investigation and **[[litespeed_wiki:​cache:​litemage:​support_tiers|support ​services]]**. This service is fully refundable if we cannot get LiteMage completely working for your site.
  
  
  • Admin
  • Last modified: 2017/05/04 13:24
  • by Jackson Zhang