This is an old revision of the document!
Loggin/logout user showing wrong info and Banner disappears 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 user 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.
Update the file header.phtml and social.phtml:
/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
according to this wiki.
In LiteMage config, enter “header” in Customized Block Names for “toplinks” Tag. Put “compare” in Additional Purge Tags for “toplinks” Blocks.
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.