2012-01-25 52 views
1

我在magento中創建了一個自定義模塊。我創建了block類和phtml文件。但是localhost/dev/index.php/testimonials/index/index沒有顯示該塊嗎?任何想法?Magento Module Block Not Working

輸出應該是 「塊裝」。相反,我得到這個http://imageshack.us/photo/my-images/525/screenshotvs.png/

UPDATE

<block type="testimonials/front" name="testimonialindex" template="front.phtml" /> 

下默認此代碼的工作handle.But它不是在<testimonials_index_index>

這裏工作代碼

<?xml version="1.0"?> 
<config> 
    <modules> 
     <Training_Testimonials> 
      <version>1.0.0</version> 
     </Training_Testimonials> 
    </modules> 

    <frontend> 
     <routers> 
      <training_testimonials> 
       <use>standard</use> 
       <args> 
        <module>Training_Testimonials</module> 
        <frontName>testimonials</frontName> 
       </args> 
      </training_testimonials> 
     </routers> 

     <layout> 
      <testimonials_layout> 

       <file>testimonials.xml</file> 
      </testimonials_layout> 
     </layout> 

    </frontend> 

    <global> 
     <blocks> 
      <testimonials> 
       <class>Training_Testimonials_Block</class> 
      </testimonials> 
     </blocks> 
     <helpers> 
      <testimonials> 
       <class>Training_Testimonials_Helper</class> 
      </testimonials> 
     </helpers> 
     <models> 
     <testimonials> <!-- group name must be uniqu --> 
      <class>Training_Testimonials_Model</class> 
      <resourceModel>testimonials_mysql4</resourceModel> 
     </testimonials> 
     <testimonials_mysql4> 
      <class>Training_Testimonials_Model_Mysql4</class> 
      <entities> 
       <manager> <!--Model name --> 
        <table>testimonials</table> 
       </manager> 
      </entities> 
     </testimonials_mysql4> 
     </models> 
     <resources> 
     <testimonials_read>   <!-- group name_ --> 
      <connection> 
       <use>core_read></use> 
     </connection> 
     </testimonials_read> 
     <testimonials_write>   <!-- group name_ --> 
      <connection> 
       <use>core_write></use> 
      </connection> 
     </testimonials_write> 
     </resources> 
    </global> 

</config> 

塊類

// app/code/local/Training/Testimonials/Block/Front.php 
    class Training_Testimonials_Block_Front extends Mage_Core_Block_Template 
    { 
     public function layout() 
     { 
      echo "Block loaded"; 
     } 
    } 

版式文件

<!-- app/design/frontend/default/wireframe/layout/testimonials.xml --> 
    <?xml version="1.0"?> 
    <layout version="0.1.0"> 
     <testimonials_index_index> 
      <reference name="content"> 
       <block type="testimonials/front" name="testimonialindex" template="front.phtml" /> 
      </reference> 
     </testimonials_index_index> 
    </layout> 
+0

鏈接被打破...... – 2012-01-25 10:23:12

+0

那是我的本地 – blakcaps

+0

什麼是你希望看到在網頁上? front.phtml文件是否顯式調用$ this-> layout()? –

回答

2

正確的代碼

<layout> 
     <updates> 
      <testimonials> 
       <file>testimonials.xml</file> 
      </testimonials> 
     </updates> 
</layout> 
0

您需要定義具有的indexAction控制器的IndexController,並做了loadLayout和renderLayout。

+0

我只發佈了一部分config.xml.Index控制器正在工作。我會發布整個配置問題 – blakcaps

+0

嘗試添加您的塊>>> public function _prepareLayout() { return parent :: _ prepareLayout(); } – Nasaralla

0

你的版本是不正確也是如此。確保每個xml文件中的模塊版本相同。

<modules> 
    <Training_Testimonials> 
     <version>1.0.0</version> 
    </Training_Testimonials> 
</modules> 

<layout version="0.1.0"> THIS SHOULD BE 1.0.0 OR THE VERSION ABOVE SHOULD BE 0.1.0 
    <testimonials_index_index> 
     <reference name="content"> 
      <block type="testimonials/front" name="testimonialindex" template="front.phtml" /> 
     </reference> 
    </testimonials_index_index> 
</layout>