简体   繁体   English

Magento LiteMage缓存-从缓存中排除块

[英]Magento LiteMage Cache - Excluding a block from caching

I have a Magento site with LiteMage cache on. 我有一个启用了LiteMage缓存的Magento网站。 My website share a common header at every pages. 我的网站在每个页面上都有一个共同的标题。 In the header, I have the following code, which checks to see if a customer is logged in to show either "Account" if logged in or "Log in" otherwise. 在标题中,我有以下代码,该代码检查是否已登录客户以显示“帐户”(如果已登录)或显示“登录”。

My problem is that, when a customer is logged in, it still shows "Log in" in some pages but "Account" at some other pages. 我的问题是,当客户登录时,它在某些页面上仍显示“登录”,而在其他页面上仍显示“帐户”。

I believe this problem is related to my cache, how do I fix this? 我相信此问题与我的缓存有关,如何解决此问题? How do I set to exclude this particular block from caching in LiteMage, if this is how it should be fixed. 如果应该解决的话,如何设置从LiteMage中缓存该特定块。

The following code is the relevant part of the codes I have at my header.phtml 以下代码是我在header.phtml中拥有的代码的相关部分

<?php
        //check the user is logged on or not
        if (! Mage::getSingleton('customer/session')->isLoggedIn()){
        //if user logged on show the logout link - add this code within anchor tag
        echo '<a href="'.Mage::helper('customer')->getLoginUrl().'">'.$this->__('Log In').'</a>';
        }
        else{
        //if user is not logged on yet show the login link - add this code within anchor tag
        echo '<a href="'.$this->getUrl('friends').'">'.$this->__('Account').'</a>';
        }
      ?>

You need to identify which block contains this code. 您需要确定哪个块包含此代码。 Like in default magento sample data, the login link is inside "top.links", and that block is hold punched. 与默认的magento样本数据一样,登录链接位于“ top.links”内,并且该框已打孔。 Try not to use the full header for it, the smaller the scope, the faster it is. 尽量不要使用完整的标头,范围越小,速度越快。 Once you know the block name, you can add that in the "customized block name for top links". 知道块名称后,可以将其添加到“自定义顶部链接的块名称”中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM