~~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, - [[litespeed_wiki:cache:litemage:troubleshooting:enabling-debug-log|Turn on the LiteMage Debug Log]]. - 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 ''
Welcome
'' - 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 not. The ESI request should be similar to ''/litemage/esi/getBlock/t/welcome/bi/welcome/h/D/s/1/dp/sm_market/dt/default/'' ==== Cause ==== Login links are not hole punched. ===== Solution ===== ==== Quick fix: Punch a big hole instead of small one through LiteMage configuration ==== You can try to punch a big hole instead of small one. Logging into the Magento Admin and entering LiteMage config, we added ''header'' in **Customized Block Names for "toplinks" Tag**. We also saw "compare" in a toplinks block, so we added ''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]]. This quick fix solution may or may not work. If not, please try to modify the theme template instead. ==== Modify the template ==== Now that we have confirmed the issue, it is time to fix it by punching a hole for the login link block, since this is private information. * 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''
getChildHtml('welcome') ?> getAdditionalHtml() ?>
helper('customer')->isLoggedIn() ){ ?>
" class="btn-head" href="getUrl('customer/account/login/') ?>">
__("Login"); ?>
__("or"); ?>
" class="btn-head" href="getUrl('customer/account/logout') ?>">
__("Logout"); ?>
helper('customer')->isLoggedIn() ){ ?>
" class="btn-head" href="customer/account/create/">
__("Create an Account"); ?>
getLayout()->createBlock('cms/block')->setBlockId('v4-call-us')->toHtml()) { ?>
getLayout()->createBlock('cms/block')->setBlockId('v4-call-us')->toHtml(); ?>
getChildHtml('topLinks');?>
* Move the logic out of ''header4.phtml'' and put it in our new ''welcomelogin.phtml'':
**[app/design/frontend/sm_market/default/template/page/html]#** ''vi welcomelogin.phtml''
helper('customer')->isLoggedIn() ){ ?>
" class="btn-head" href="getUrl('customer/account/login/') ?>">
__("Login"); ?>
__("or"); ?>
" class="btn-head" href="getUrl('customer/account/logout') ?>">
__("Logout"); ?>
helper('customer')->isLoggedIn() ){ ?>
" class="btn-head" href="customer/account/create/">
__("Create an Account"); ?>
* Next we call the new block ''welcomelogin'', modify the layout file, and add our new welcomelogin block inside the header block:
**[app/design/frontend/sm_market/default/layout]#** ''vi page.xml''
….
…. After the welcome block
* Update ''header4.phtml'' using the new welcomelogin block:
**[app/design/frontend/sm_market/default/template/page/html]#** ''vi header4.phtml''
getChildHtml('welcome') ?> getAdditionalHtml() ?>
getChildHtml('welcomelogin'); ?>
getLayout()->createBlock('cms/block')->setBlockId('v4-call-us')->toHtml()) { ?>
getLayout()->createBlock('cms/block')->setBlockId('v4-call-us')->toHtml(); ?>
getChildHtml('topLinks');?>
* 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.