2012-07-29 193 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