This is an old revision of the document!


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.

Issue 1: Login/Logout issue

At Home page, there is one section at the top which says “Welcome Login or Create an Account”. With LiteMage enabled, If a 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 “Welcome, hole Logout” if a user is logged in. In that case, for other users which just opened the home page, it shows, “Welcome, Logout”.

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 button, with welcome tag.

Global PHP variables can not be initialized in header.phtml and social.phtml, update those two files:

/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)) {
      include (dirname(dirname(__FILE__)).'/sm/yt_prepar.php');
}

according to this wiki.

After initialization problem resolved, we need to punch a big hole instead of small one. In MagentoAdmin LiteMage config, enter “header” in Customized Block Names for “toplinks” Tag.

Issue 2: compare issue

Put “compare” in Additional Purge Tags for “toplinks” Blocks.

Issue 3: banner disappear issue

The above solutions fixed Loggin/logout user showing wrong info issue. But due to the changes, the banner disappears from homepage.

After further investigation, we found out the header template includes logic to check if it's frontend or not. If it is frontend, then it show banner. So we cannot simply punch a big hole for the header.

The solution is go back to fix the login links. We 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.

Copy original files as .bak.

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.

<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(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 } ?>
              </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 [app/design/frontend/sm_market/default/layout]# vi page.xml

Insider header block we add our new “welcomelogin” block:

<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(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="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. Banner shows up.

In real-time, the 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 our support here.

  • Admin
  • Last modified: 2017/05/04 13:27
  • by Jackson Zhang