Magento 1.9.2.0静态块显示问题?我在1.9.2.0中创建多个静态块并显示错误的块如何解决这个问题。
toe950271#
尝试以下模块可能会有帮助**1步骤.**创建根路径:app\etc\modules潘卡吉_合同. xml
app\etc\modules
<?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
app\code\local\Pankaj\Cms\Block
<?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
app\code\local\Pankaj\Cms\Block\Widget
<?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; } }
然后清除缓存
1条答案
按热度按时间toe950271#
尝试以下模块可能会有帮助**1步骤.**创建根路径:
app\etc\modules
潘卡吉_合同. xml2步骤创建根路径:应用程序\代码\本地\Pankaj\Cms\等
3步骤创建根路径:
app\code\local\Pankaj\Cms\Block
块. php4步骤创建根路径
app\code\local\Pankaj\Cms\Block\Widget
Block.php然后清除缓存