Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/magento/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Magento模块块不工作_Magento - Fatal编程技术网

Magento模块块不工作

Magento模块块不工作,magento,Magento,我正在magento中创建一个自定义模块。我已经创建了block类和phtml文件。但是localhost/dev/index.php/testicials/index/index没有显示该块?有什么想法吗 输出应该是“块加载”。我得到的是 更新 <block type="testimonials/front" name="testimonialindex" template="front.phtml" /> 布局文件 <!-- app/design/frontend/def

我正在magento中创建一个自定义模块。我已经创建了block类和phtml文件。但是localhost/dev/index.php/testicials/index/index没有显示该块?有什么想法吗

输出应该是“块加载”。我得到的是

更新

<block type="testimonials/front" name="testimonialindex" template="front.phtml" />
布局文件

<!-- 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>

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

正确的代码是

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

emissionals.xml

您的版本控制也不正确。确保每个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>

1.0.0
这应该是1.0.0,或者上面的版本应该是0.1.0

我只发布了config.xml.Index控制器的一部分。我将发布有问题的整个配置尝试添加到您的块>>>公共函数_prepareLayout(){返回父项::_prepareLayout();}。您希望在页面上看到什么?front.phtml文件是否显式调用$this->layout()?
<layout>
       <updates>
            <testimonials> 
                <file>testimonials.xml</file>
            </testimonials>
       </updates>
</layout> 
<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>