我在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>
鏈接被打破...... – 2012-01-25 10:23:12
那是我的本地 – blakcaps
什麼是你希望看到在網頁上? front.phtml文件是否顯式調用$ this-> layout()? –