This is an old revision of the document!


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. To investigate this issue,

  1. first turn on LiteMage debug log.
  2. 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>
  3. 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/

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.

  • In sm_market config, check the header style selection. For this site, it is header4
  • 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 template, so we can punch a hole for that block.
[app/design/frontend/sm_market/default/template/page/html]# vi header4.phtml
	<div class="yt-header-top">
	    <div class="container">
	        <div class="row">
	            <div class="header-top-1 col-lg-4 col-md-4 col-sm-6 col-xs-12">
	                <div class="inner">
	                    <p class="welcome-msg"><?php echo $this->getChildHtml('welcome') ?> <?php echo $this->getAdditionalHtml() ?></p>
	                    <div class="login-regis">
	                       <?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 } ?>
	                    </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>
  • We call the new block “welcomelogin”, Modify layout file, inside header block we add our new “welcomelogin” block.
[app/design/frontend/sm_market/default/layout]# vi page.xml
<block type="page/html_header" name="header" as="header">
….
…. 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/template/page/html]# vi welcomelogin.phtml
                      <?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 } ?>
  • Update header4.phtml, using the new welcomelogin block
[app/design/frontend/sm_market/default/template/page/html]# vi header4.phtml
<div class="yt-header-top">
    <div class="container">
      <div class="row">
          <div class="header-top-1 col-lg-4 col-md-4 col-sm-6 col-xs-12">
              <div class="inner">
                  <p class="welcome-msg"><?php echo $this->getChildHtml('welcome') ?> <?php echo $this->getAdditionalHtml() ?></p>
                  <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>

* Go to Magento admin panel LiteMage Configuration, add “welcomelogin” to Customized Block Names for "welcome" Tag  
  • Flush LiteMage cache, then we can verify that welcomelogin has been properly hole punched.
  • Admin
  • Last modified: 2017/01/30 17:57
  • by Lauren Song