2012-07-29 192 views
3

我不知道为什么我的块没有显示出来。它没有显示在任何页面上,我清除了缓存。有人能帮我弄清楚我错过了什么吗?但是,var_dump('test')显示!为什么我的块没有显示?

应用程序/设计/前端/预设/默认/模板/贾斯汀/ head.phtml

testing this block 

贾斯汀/比伯/座/ Sings.php

class Justin_Bieber_Block_Sings extends Mage_Core_Block_Template 
{ 
    protected function _construct() 
    { 
     parent::_construct(); 
     var_dump("test"); 
    } 
} 

config.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> 

回答

1

在你justin.xml块型应该是

<block type="bieber/sings" name="justin_bieber"> 

在这种情况下,“比伯”是你的模块别名和“唱”是类的名称。

+0

我同意@blakcaps。模块类型“bieber/bieber”是错误的 – 2012-07-29 09:15:20

+0

我改变了它,但它仍然不起作用。我可能会做错什么? – Strawberry 2012-07-30 00:47:42

1


你的代码对我来说似乎很好。
关于justin.xml尝试将其更改为以下:

<?xml version="1.0"?> 
<layout version="0.1.0"> 
    <default> 
     <reference name="head"> 
      <block type="bieber/sings" name="justin_bieber" as="justin_bieber" template="justin/head.phtml" /> 
     </reference> 
    </default> 
</layout> 

让我知道你的作品!

+0

我也试过,但没有去:( – Strawberry 2012-07-30 00:51:36