首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Magento模块块不工作

Magento模块块不工作
EN

Stack Overflow用户
提问于 2012-01-25 10:08:12
回答 3查看 3.6K关注 0票数 1

我正在用magento.I创建一个自定义模块,我已经创建了块类,而phtml file.But file.But没有显示块吗?有什么想法吗?

输出应该是“块加载”.Instead我得到了这个http://imageshack.us/photo/my-images/525/screenshotvs.png/

更新

代码语言:javascript
复制
<block type="testimonials/front" name="testimonialindex" template="front.phtml" />

此代码在默认的handle.But下工作,它在<testimonials_index_index>中不工作。

这是代码

代码语言:javascript
复制
<?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>

块类

代码语言:javascript
复制
 // app/code/local/Training/Testimonials/Block/Front.php
    class Training_Testimonials_Block_Front extends Mage_Core_Block_Template
    {
        public function layout()
        {
            echo "Block loaded";
        }
    }

布局文件

代码语言:javascript
复制
<!-- 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>
EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2012-02-24 07:53:34

正确的代码是

代码语言:javascript
复制
<layout>
       <updates>
            <testimonials> 
                <file>testimonials.xml</file>
            </testimonials>
       </updates>
</layout> 
票数 2
EN

Stack Overflow用户

发布于 2012-01-25 10:52:35

您需要使用IndexAction定义控制器IndexAction,并执行loadLayout和renderLayout。

票数 0
EN

Stack Overflow用户

发布于 2013-02-06 17:17:59

您的版本控制也不正确。确保模块版本在每个xml文件中是相同的。

代码语言:javascript
复制
<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>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/9000846

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档