我不知道为什么我的区 block 没有显示。它没有显示在任何页面上,我清除了缓存。有人可以帮我弄清楚我错过了什么吗?但是,var_dump('test')
出现了!
app/design/frontend/default/default/template/justin/head.phtml
testing this block
贾斯汀/比伯/Block/Sings.php
class Justin_Bieber_Block_Sings extends Mage_Core_Block_Template
{
protected function _construct()
{
parent::_construct();
var_dump("test");
}
}
配置.xml
<frontend>
...
<layout>
<updates>
<bieber>
<file>justin.xml</file>
</bieber>
</updates>
</layout>
</frontend>
<global>
<blocks>
<bieber>
<class>Justin_Bieber_Block</class>
</bieber>
</blocks>
...
</global>
app/design/frontend/default/default/layout/justin.xml
<?xml version="1.0"?>
<layout version="0.1.0">
<default>
<reference name="head">
<block type="bieber/bieber" name="justin_bieber">
<action method="setTemplate">
<template>justin/head.phtml</template>
</action>
</block>
</reference>
</default>
</layout>
最佳答案
在你的 justin.xml block 类型中应该是
<block type="bieber/sings" name="justin_bieber">
在本例中,“bieber”是您的模块别名,“sings”是类名。
关于magento - 为什么我的区 block 没有显示?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11705812/