在CMS静态页面中使用自定义块

时间:2016-05-04 12:52:44

标签: magento

我试图从magento cms static block调用我的块,但它不起作用。

本地/ Mymodule中/测试的/ etc / config.xml中

<config>
    <modules>
        <Mymodule_Test>
            <version>1.0.0</version>
        </Mymodule_Test>
    </modules>
    <global>
        <blocks>
            <test>
                <class>Mymodule_Test_Block</class>
            </test>
        </blocks>
    </global>
</config>

本地/ Mymodule中/测试/块/ Testblock.php

class Mymodule_Test_Block_Testblock extends Mage_Core_Block_Template
{

}

在我的静态cms页面中,我使用

{{block type="test/testblock" template="page/test.phtml"}}

我假设在调用

时块模板正确放置了bcus
{{block type="core/template" template="page/test.phtml"}}

这没有问题。

error.log中

2016-05-04T12:43:51+00:00 ERR (3): 
exception 'Exception' with message 'Notice: Undefined variable: block  in C:\xampp5-6-14\htdocs\project\app\code\core\Mage\Core\Model\Email\Template\Filter.php on line 187' in C:\xampp5-6-14\htdocs\project\app\code\core\Mage\Core\functions.php:245
Stack trace:
#0 C:\xampp5-6-14\htdocs\project\app\code\core\Mage\Core\Model\Email\Template\Filter.php(187): mageCoreErrorHandler(8, 'Undefined varia...', 'C:\\xampp5-6-14\\...', 187, Array)
#1 [internal function]: Mage_Core_Model_Email_Template_Filter->blockDirective(Array)
#2 C:\xampp5-6-14\htdocs\project\lib\Varien\Filter\Template.php(163): call_user_func(Array, Array)
#3 C:\xampp5-6-14\htdocs\project\app\code\core\Mage\Core\Model\Email\Template\Filter.php(558): Varien_Filter_Template->filter('<p>{{block type...')
#4 C:\xampp5-6-14\htdocs\project\app\code\core\Mage\Cms\Block\Page.php(101): Mage_Core_Model_Email_Template_Filter->filter('<p>{{block type...')
#5 C:\xampp5-6-14\htdocs\project\app\code\core\Mage\Core\Block\Abstract.php(919): Mage_Cms_Block_Page->_toHtml()
#6 C:\xampp5-6-14\htdocs\project\app\code\core\Mage\Core\Block\Abstract.php(637): Mage_Core_Block_Abstract->toHtml()
#7 C:\xampp5-6-14\htdocs\project\app\code\core\Mage\Core\Block\Abstract.php(577): Mage_Core_Block_Abstract->_getChildHtml('cms_page', true)
#8 C:\xampp5-6-14\htdocs\project\app\code\core\Mage\Page\Block\Html\Wrapper.php(52): Mage_Core_Block_Abstract->getChildHtml('', true, true)
#9 C:\xampp5-6-14\htdocs\project\app\code\core\Mage\Core\Block\Abstract.php(919): Mage_Page_Block_Html_Wrapper->_toHtml()
#10 C:\xampp5-6-14\htdocs\project\app\code\core\Mage\Core\Block\Text\List.php(43): Mage_Core_Block_Abstract->toHtml()
#11 C:\xampp5-6-14\htdocs\project\app\code\core\Mage\Core\Block\Abstract.php(919): Mage_Core_Block_Text_List->_toHtml()
#12 C:\xampp5-6-14\htdocs\project\app\code\core\Mage\Core\Block\Abstract.php(637): Mage_Core_Block_Abstract->toHtml()
#13 C:\xampp5-6-14\htdocs\project\app\code\core\Mage\Core\Block\Abstract.php(581): Mage_Core_Block_Abstract->_getChildHtml('content', true)
#14 C:\xampp5-6-14\htdocs\project\app\design\frontend\mydesign\system\template\page\1column.phtml(55): Mage_Core_Block_Abstract->getChildHtml('content')
#15 C:\xampp5-6-14\htdocs\project\app\code\core\Mage\Core\Block\Template.php(241): include('C:\\xampp5-6-14\\...')
#16 C:\xampp5-6-14\htdocs\project\app\code\core\Mage\Core\Block\Template.php(272): Mage_Core_Block_Template->fetchView('frontend\\myde...')
#17 C:\xampp5-6-14\htdocs\project\app\code\core\Mage\Core\Block\Template.php(286): Mage_Core_Block_Template->renderView()
#18 C:\xampp5-6-14\htdocs\project\app\code\core\Mage\Core\Block\Abstract.php(919): Mage_Core_Block_Template->_toHtml()
#19 C:\xampp5-6-14\htdocs\project\app\code\core\Mage\Core\Model\Layout.php(555): Mage_Core_Block_Abstract->toHtml()
#20 C:\xampp5-6-14\htdocs\project\app\code\core\Mage\Core\Controller\Varien\Action.php(390): Mage_Core_Model_Layout->getOutput()
#21 C:\xampp5-6-14\htdocs\project\app\code\core\Mage\Cms\Helper\Page.php(137): Mage_Core_Controller_Varien_Action->renderLayout()
#22 C:\xampp5-6-14\htdocs\project\app\code\core\Mage\Cms\Helper\Page.php(52): Mage_Cms_Helper_Page->_renderPage(Object(Mage_Cms_IndexController), 'home')
#23 C:\xampp5-6-14\htdocs\project\app\code\core\Mage\Cms\controllers\IndexController.php(45): Mage_Cms_Helper_Page->renderPage(Object(Mage_Cms_IndexController), 'home')
#24 C:\xampp5-6-14\htdocs\project\app\code\core\Mage\Core\Controller\Varien\Action.php(418): Mage_Cms_IndexController->indexAction()
#25 C:\xampp5-6-14\htdocs\project\app\code\core\Mage\Core\Controller\Varien\Router\Standard.php(254): Mage_Core_Controller_Varien_Action->dispatch('index')
#26 C:\xampp5-6-14\htdocs\project\app\code\core\Mage\Core\Controller\Varien\Front.php(172): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#27 C:\xampp5-6-14\htdocs\project\app\code\core\Mage\Core\Model\App.php(365): Mage_Core_Controller_Varien_Front->dispatch()
#28 C:\xampp5-6-14\htdocs\project\app\Mage.php(684): Mage_Core_Model_App->run(Array)
#29 C:\xampp5-6-14\htdocs\project\index.php(102): Mage::run('', 'store')
#30 {main}

任何想法为什么电子邮件模板过滤器甚至被调用?

这适用于Magento Enterpise,但出于某种原因我无法添加标签:v

1 个答案:

答案 0 :(得分:0)

我发现类似的问题可能是正确的解决方案 - 检查一下: https://tomlankhorst.nl/fix-magento-1-9-2-2-notice-undefined-variable-block/

TLDR:

  1. 转到后端&gt;系统&gt;权限&gt;块
  2. 添加您喜欢的块 - 例如。 test / testblock (允许)
  3. 就绪<!/ LI>