Magento 1.9.2.0静态块显示问题?

qxsslcnc  于 2022-11-12  发布在  其他
关注(0)|答案(1)|浏览(127)

Magento 1.9.2.0静态块显示问题?我在1.9.2.0中创建多个静态块并显示错误的块如何解决这个问题。

toe95027

toe950271#

尝试以下模块可能会有帮助**1步骤.**创建根路径:app\etc\modules潘卡吉_合同. xml

<?xml version="1.0"?>
<config>
    <modules>
        <Pankaj_Cms>
            <active>true</active>
            <codePool>local</codePool>
            <depends>
                <Mage_Cms/>
            </depends>
        </Pankaj_Cms>
    </modules>
</config>

2步骤创建根路径:应用程序\代码\本地\Pankaj\Cms\等

<?xml version="1.0"?>
    <config>
            <modules>
                <Pankaj_Cms>
                    <version>1.0.0</version>
                </Pankaj_Cms>
            </modules>
            <global>
                <blocks>
                    <cms>
                        <rewrite>
                            <block>Pankaj_Cms_Block_Block</block>
                            <widget_block>Pankaj_Cms_Block_Widget_Block</widget_block>
                        </rewrite>
                    </cms>
                </blocks>
            </global>
    </config>

3步骤创建根路径:app\code\local\Pankaj\Cms\Block块. php

<?php
class Pankaj_Cms_Block_Block extends Mage_Cms_Block_Block {

   public function getCacheKeyInfo()
    {

      $blockId = $this->getBlockId();
      if ($blockId) {
            $result = array(
                $blockId,
                Mage::app()->getStore()->getCode(),
            );
      } else {
           $result = parent::getCacheKeyInfo();
       }
       return $result;
   }

}

4步骤创建根路径app\code\local\Pankaj\Cms\Block\Widget Block.php

<?php
class Pankaj_Cms_Block_Widget_Block extends Mage_Cms_Block_Widget_Block
{
    static protected $_widgetUsageMap = array();
    protected function _beforeToHtml()
    {
        parent::_beforeToHtml();
        $blockId = $this->getData('block_id');
        $blockHash = get_class($this) . $blockId;

        if (isset(self::$_widgetUsageMap[$blockHash])) {
            return $this;
        }
        self::$_widgetUsageMap[$blockHash] = true;

        if ($blockId) {
            $block = Mage::getModel('cms/block')
                ->setStoreId(Mage::app()->getStore()->getId())
                ->load($blockId);
            if ($block->getIsActive()) {
                $helper = Mage::helper('cms');
                $processor = $helper->getBlockTemplateProcessor();
                $this->setText($processor->filter($block->getContent()));
                $this->addModelTags($block);
            }
        }

        unset(self::$_widgetUsageMap[$blockHash]);
        return $this;
    }
    public function getCacheKeyInfo()
    {
        $result = parent::getCacheKeyInfo();
        $blockId = $this->getBlockId();
        if ($blockId) {
            $result[] = $blockId;
       }
        return $result;
   }
}

然后清除缓存

相关问题