简体   繁体   English

Magento删除块仅适用于禁用缓存

[英]Magento remove block only works with cache disabled

I have a static block that gets added to the footer reference on every page. 我有一个静态块,它被添加到每个页面的页脚引用。 My homepage is a CMS page and I've put code in the pages Layout Update XML to remove the block from that page. 我的主页是一个CMS页面,我将代码放在Layout Update XML页面中,以从该页面中删除该块。

This is how it's added to the footer for all pages: 这是它添加到所有页面的页脚的方式:

In page.xml inside 在page.xml里面

<reference name="footer">
  <block type="cms/block" name="page_cta" before="-">
    <action method="setBlockId"><block_id>page_cta</block_id></action>
  </block>
</reference>

Code in my homepages layout update xml to remove the block: 我的主页布局中的代码更新xml以删除块:

<reference name="footer">
  <remove name="page_cta" />
</reference>

The block shouldn't show on the homepage and should show on all other pages. 该块不应显示在主页上,并应显示在所有其他页面上。 This works fine but only if the cache is disabled. 这工作正常,但只有在禁用缓存时。 What seems to happen is the cache is enabled then I view the homepage and the block is removed but then it is also removed on every other page. 似乎发生了什么是启用了缓存然后我查看了主页并删除了块,但随后它也被删除了每个其他页面。

Can anyone shed some light on why this doesn't work if the cache is enabled? 任何人都可以解释为什么如果启用缓存这不起作用?

Disable the cache for specific block like as mentioned below: 禁用特定块的缓存,如下所述:

<reference name="footer">
       <action method="unsetData"><key>cache_lifetime</key></action>
       <action method="unsetData"><key>cache_tags</key></action>
       <block type="cms/block" name="page_cta" before="-">
           <action method="setBlockId"><block_id>page_cta</block_id></action>
       </block>
   </reference>

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

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