magento 底部footer部分setemplate 无效的解决方式

Hello 
Here is how I usually do it when I have the same issue. 
I change the cache key for the footer to make 2 different cache files, depending on the page. 
Fist of all add a new property to the footer for the page that is different. 
In your case make the layout for the footer like this:

<cms_index_index>
    <reference name="footer">
            <action method="setTemplate"><template>mymodule/mymodule-footerblock/mymodule-footerblock-home.phtml</template></action>
            <action method="setHomepageFooter"><value>1</value></action><!-- the way you name your method is not important -->
    </reference>
</cms_index_index>
now override the Mage_Page_Block_Html_Footer in order to change the cache key. To override the block follow this tutorial: http://magedev.com/2009/06/03/magento-overriding-model-block-or-helper/

In your new class that overrides the footer block add this method. 
public function getCacheKeyInfo(){
 $info = parent::getCacheKeyInfo();
$info[] = (int)$this->getHomepageFooter();//same method as in the layout file but use get instead of set.
return $info;
}
This is really helpful if you want to have other pages with different footer. 
Just add a line in the layout file for the page you want a different footer 
<action method="setCustomMethodName"><value>1</value></action>
and in the getCacheKeyInfo method add a new line: 
$info[] = (int)$this->getCustomMethodName();
It works perfectly for me.

Cheers, 
Marius.

如果您懒的写,懒的看,那么下载我写的插件吧,下载地址为:

http://download.csdn.net/detail/terry_water/7097161


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值