Differences

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

Link to this comparison view

Next revision
Previous revision
Next revision Both sides next revision
litespeed_wiki:cache:litemage:troubleshooting:login-link-still-show-after-logged-in [2017/01/30 17:57]
Lauren Song created
litespeed_wiki:cache:litemage:troubleshooting:login-link-still-show-after-logged-in [2017/10/25 14:18]
Jackson Zhang [Login/Create an Account Links Appearing While Logged In]
Line 1: Line 1:
-In sm_market yt theme, with the default LiteMage installation, ​"Login or Create an Account" ​links in header still shows after a user logged in.+~~NOTOC~~ 
 +====== "​Login/​Create an Account"​ Links Appearing While Logged ​In (block hole punch required) ====== 
 + 
 +==== Problem ==== 
 +In the sm_market yt theme, with the default LiteMage installation, ​**Login or Create an Account** links in the header ​are still appearing even after a user has logged in. 
 To investigate this issue, ​ To investigate this issue, ​
-  - first [[litespeed_wiki:​cache:​litemage:​troubleshooting:​enabling-debug-log|turn on]] LiteMage debug log+  - [[litespeed_wiki:​cache:​litemage:​troubleshooting:​enabling-debug-log|Turn on the LiteMage Debug Log]]. 
-  - add "?​LITEMAGE_DEBUG=SHOWHOLES" after a URL, now we see only welcome is inside a punched hole, but not the login links. If you do not use any html minifier, you can also see the hole punched block when you inspect ​the html source. ​You can see something ​like ''<​p class="​welcome-msg"><​!--Litemage esi started welcome-->​Welcome<​!--Litemage esi ended welcome-->​ </​p>''​ +  - Add query string ''​?​LITEMAGE_DEBUG=SHOWHOLES''​ to the end of a URL on your site. You should ​see that only welcome is inside a punched hole, while the login links are not. If you do not use an HTML minifier, you can also see the hole punched block when inspecting ​the HTML source. ​In the source, you will see something ​similar to ''<​p class="​welcome-msg"><​!--Litemage esi started welcome-->​Welcome<​!--Litemage esi ended welcome-->​ </​p>''​ 
-  - check log output ​(var/​log/​system.log), ''​tail -f system.log | grep LiteMage'' ​and we can see the welcome block is hole punched, but not the login link. Esi request ​is like ''/​litemage/​esi/​getBlock/​t/​welcome/​bi/​welcome/​h/​D/​s/​1/​dp/​sm_market/​dt/​default/''​+  - Check the logs output ​for LiteMage related messages with the following command, ''​tail -f var/log/system.log | grep LiteMage''​. You should again see that the welcome block is hole punched ​while the login link is notThe ESI request ​should be similar to ''/​litemage/​esi/​getBlock/​t/​welcome/​bi/​welcome/​h/​D/​s/​1/​dp/​sm_market/​dt/​default/''​
  
-We have confirmed the issue, ​now to fix this, we need to punch a hole for the login link block since this is private information. +==== Solution ==== 
-  * In sm_market config, check the header style selection. For this site, it is header4 +Now that we have confirmed the issue, ​it is time to fix it by punching ​a hole for the login link blocksince this is private information. 
-  * Look at header4.phtml code, 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 templateso we can punch a hole for that block.+  * In your sm_market config, check the header style selection. For this site, it is ''​header4''​ 
 +  * Looking ​at the ''​header4.phtml'' ​code, we can see that the logged in link is mixed into the header template. We need to take that logic out and put in its own block and template so that we can punch a hole for that block:
  
-  ​[app/​design/​frontend/​sm_market/​default/​template/​page/​html]#​ vi header4.phtml+**[app/​design/​frontend/​sm_market/​default/​template/​page/​html]#​** ''​vi header4.phtml''​
  
- <div class="​yt-header-top">​ +<​code>​ 
-     ​<div class="​container">​ +<div class="​yt-header-top">​ 
-         ​<div class="​row">​ + <div class="​container">​ 
-             ​<div class="​header-top-1 col-lg-4 col-md-4 col-sm-6 col-xs-12">​ + <div class="​row">​ 
-                 ​<div class="​inner">​ + <div class="​header-top-1 col-lg-4 col-md-4 col-sm-6 col-xs-12">​ 
-                     ​<p class="​welcome-msg"><?​php echo $this->​getChildHtml('​welcome'​) ?> <?php echo $this->​getAdditionalHtml() ?></​p>​ + <div class="​inner">​ 
-                     ​<div class="​login-regis">​ + <p class="​welcome-msg"><?​php echo $this->​getChildHtml('​welcome'​) ?> <?php echo $this->​getAdditionalHtml() ?></​p>​ 
-                        <?php if(!$this->​helper('​customer'​)->​isLoggedIn() ){ ?> + <div class="​login-regis">​ 
-                             ​<a title="<?​php echo $this->​__("​Login"​);​ ?>" class="​btn-head"​ href="<?​php echo $this->​getUrl('​customer/​account/​login/'​) ?>">​ +    <?php if(!$this->​helper('​customer'​)->​isLoggedIn() ){ ?> 
-                                 ​<?php echo $this->​__("​Login"​);​ ?> + <a title="<?​php echo $this->​__("​Login"​);​ ?>" class="​btn-head"​ href="<?​php echo $this->​getUrl('​customer/​account/​login/'​) ?>">​ 
-                             ​</​a>​ + <?php echo $this->​__("​Login"​);​ ?> 
-                             ​<?php echo $this->​__("​or"​);​ ?> + </​a>​ 
-                         ​<?php } else{ ?> + <?php echo $this->​__("​or"​);​ ?> 
-                             ​<a title="<?​php echo $this->​__("​Logout"​);​ ?>" class="​btn-head"​ href="<?​php echo $this->​getUrl('​customer/​account/​logout'​) ?>">​ + <?php } else{ ?> 
-                                 ​<?php echo $this->​__("​Logout"​);​ ?> + <a title="<?​php echo $this->​__("​Logout"​);​ ?>" class="​btn-head"​ href="<?​php echo $this->​getUrl('​customer/​account/​logout'​) ?>">​ 
-                             ​</​a>​ + <?php echo $this->​__("​Logout"​);​ ?> 
-                         ​<?php } ?> + </​a>​ 
-                         ​<?php + <?php } ?> 
-                         ​if(!$this->​helper('​customer'​)->​isLoggedIn() ){ ?> + <?php 
-                             ​<a title="<?​php echo $this->​__("​Create an Account"​);​ ?>" class="​btn-head"​ href="<?​php echo Mage::​getBaseUrl();​ ?>​customer/​account/​create/">​ + if(!$this->​helper('​customer'​)->​isLoggedIn() ){ ?> 
-                             ​<?php echo $this->​__("​Create an Account"​);​ ?></​a>​ + <a title="<?​php echo $this->​__("​Create an Account"​);​ ?>" class="​btn-head"​ href="<?​php echo Mage::​getBaseUrl();​ ?>​customer/​account/​create/">​ 
-                         ​<?php } ?> + <?php echo $this->​__("​Create an Account"​);​ ?></​a>​ 
-                     ​</​div>​ + <?php } ?> 
-                 ​</​div>​ + </​div>​ 
-             ​</​div>​ + </​div>​ 
-             ​<div class="​header-top-2 col-lg-4 col-md-4 col-sm-6 col-xs-12">​ + </​div>​ 
-                 ​<?php if($this->​getLayout()->​createBlock('​cms/​block'​)->​setBlockId('​v4-call-us'​)->​toHtml()) { ?> + <div class="​header-top-2 col-lg-4 col-md-4 col-sm-6 col-xs-12">​ 
-                     ​<?php echo $this->​getLayout()->​createBlock('​cms/​block'​)->​setBlockId('​v4-call-us'​)->​toHtml();​ ?> + <?php if($this->​getLayout()->​createBlock('​cms/​block'​)->​setBlockId('​v4-call-us'​)->​toHtml()) { ?> 
-                 ​<?php } ?> + <?php echo $this->​getLayout()->​createBlock('​cms/​block'​)->​setBlockId('​v4-call-us'​)->​toHtml();​ ?> 
-             ​</​div>​ + <?php } ?> 
-             ​<div class="​header-top-3 col-lg-4 col-md-4 col-sm-6 col-xs-12">​ + </​div>​ 
-                 ​<div class="​inner">​ + <div class="​header-top-3 col-lg-4 col-md-4 col-sm-6 col-xs-12">​ 
-                     ​<div class="​head-quicklink">​ + <div class="​inner">​ 
-                         ​<?php echo $this->​getChildHtml('​topLinks'​);?>​ + <div class="​head-quicklink">​ 
-                     ​</​div>​ + <?php echo $this->​getChildHtml('​topLinks'​);?>​ 
-                 ​</​div>​ + </​div>​ 
-             </​div>​ + </​div>​ 
-         </​div>​ + </​div>​
-     ​</​div>​+
  </​div>​  </​div>​
 + </​div>​
 +</​div>​
 +</​code>​
  
-  * We call the new block “welcomelogin”,​ Modify layout file, inside header block we add our new welcomelogin” block+  * Move the logic out of ''​header4.phtml''​ and put it in our new ''​welcomelogin.phtml'':​
  
-  ​[app/​design/​frontend/​sm_market/​default/​layout]# vi page.xml+**[app/​design/​frontend/​sm_market/​default/​template/​page/​html]#** ''​vi welcomelogin.phtml''​ 
 +<​code>​ 
 +<?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(!$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">​ +  ​* Next we call the new block ''​welcomelogin'',​ modify the layout file, and add our new welcomelogin block inside 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+**[app/​design/​frontend/​sm_market/​default/​layout]#​** ''​vi page.xml''​
  
-  [app/design/​frontend/​sm_market/​default/template/page/html]# vi welcomelogin.phtml+<​code>​ 
 +<block type="​page/html_header"​ name="​header"​ as="​header">​ 
 +…. 
 +…. After the welcome block 
 +<block type="​core/template" name="​welcomelogin"​ as="​welcomelogin"​ template="​page/html/welcomelogin.phtml"/>​ 
 +</​code>​
  
 +  * Update ''​header4.phtml''​ using the new welcomelogin block:
  
-                        <?php if(!$this->​helper('​customer'​)->​isLoggedIn() ){ ?> +**[app/​design/​frontend/​sm_market/​default/​template/​page/​html]#​** ''​vi header4.phtml''​ 
-                            <a title="<?​php echo $this->​__("​Login"​);​ ?>" class="​btn-head"​ href="<?​php echo $this->​getUrl('​customer/​account/​login/'​) ?>">​ +<​code>​ 
-                                <?php echo $this->​__("​Login"​);​ ?> +<div class="​yt-header-top">​ 
-                            </​a>​ +  <div class="​container">​ 
-                            <?php echo $this->​__("​or"​);​ ?> + <div class="​row">​ 
-                        <?php } else{ ?> + <div class="​header-top-1 col-lg-4 col-md-4 col-sm-6 col-xs-12">​ 
-                            <a title="<?​php echo $this->​__("​Logout"​);​ ?>" class="​btn-head"​ href="<?​php echo $this->​getUrl('​customer/​account/​logout'​) ?>">​ + <div class="​inner">​ 
-                                <?php echo $this->​__("​Logout"​);​ ?> + <p class="​welcome-msg"><?​php echo $this->​getChildHtml('​welcome'​) ?> <?php echo $this->​getAdditionalHtml() ?></​p>​ 
-                            </​a>​ + <div class="​login-regis">​ 
-                        <?php } ?> +   ​<?php echo $this->​getChildHtml('​welcomelogin'​);​ ?>  
-                        <?php + </​div>​ 
-                        if(!$this->​helper('​customer'​)->​isLoggedIn() ){ ?> + </​div>​ 
-                            <a title="<?​php echo $this->​__("​Create an Account"​);​ ?>" class="​btn-head"​ href="<?​php echo Mage::​getBaseUrl();​ ?>​customer/​account/​create/">​ + </​div>​ 
-                            <?php echo $this->​__("​Create an Account"​);​ ?></​a>​ + <div class="​header-top-2 col-lg-4 col-md-4 col-sm-6 col-xs-12">​ 
-                        <?php } ?> + <?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 } ?> 
-  ​Update header4.phtml,​ using the new welcomelogin block + </​div>​ 
- + <div class="​header-top-3 col-lg-4 col-md-4 col-sm-6 col-xs-12">​ 
-  ​[app/​design/​frontend/​sm_market/​default/​template/​page/​html]#​ vi header4.phtml + <div class="​inner">​ 
-  <div class="​yt-header-top">​ + <div class="​head-quicklink">​ 
-      <div class="​container">​ + <?php echo $this->​getChildHtml('​topLinks'​);?>​ 
-        <div class="​row">​ + </​div>​ 
-            <div class="​header-top-1 col-lg-4 col-md-4 col-sm-6 col-xs-12">​ + </​div>​ 
-                <div class="​inner">​ + </​div>​ 
-                    <p class="​welcome-msg"><?​php echo $this->​getChildHtml('​welcome'​) ?> <?php echo $this->​getAdditionalHtml() ?></​p>​ + </​div>​
-                    <div class="​login-regis">​ +
-                    <?php echo $this->​getChildHtml('​welcomelogin'​);​ ?> +
-                    </​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>​ 
-  * Go to Magento admin panel LiteMage Configuration,​ add “welcomelogin” to Customized Block Names for "​welcome"​ Tag   +</​code>​
- +
-  * Flush LiteMage cache, then we can verify that welcomelogin has been properly hole punched. +
  
 +  * Go to the **LiteMage Configuration** section of your Magento admin panel and add ''​welcomelogin''​ to the **Customized Block Names for "​welcome"​ Tag** field.  ​
  
 +  * Flush LiteMage cache, and verify that welcomelogin has been properly hole punched.
  • Admin
  • Last modified: 2018/07/16 13:06
  • by Jackson Zhang