Модуль модуля Magento не работает - PullRequest
1 голос
/ 25 января 2012

Я создаю пользовательский модуль в magento. Я создал класс блока и файл phtml. Но localhost / dev / index.php / testimonials / index / index не показывает блок? Есть идеи?

Вывод должен быть "загружен блоком". Вместо этого я получаю это http://imageshack.us/photo/my-images/525/screenshotvs.png/

UPDATE

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

этот код работает под дескриптором по умолчанию. Но он не работает в <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>

Ответы [ 3 ]

2 голосов
/ 24 февраля 2012

Правильный код

<layout>
       <updates>
            <testimonials> 
                <file>testimonials.xml</file>
            </testimonials>
       </updates>
</layout> 
0 голосов
/ 06 февраля 2013

Ваши версии также неверны.Убедитесь, что версии вашего модуля одинаковы в каждом 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>
0 голосов
/ 25 января 2012

Вам необходимо определить контроллер IndexController с помощью IndexAction и выполнить loadLayout и renderLayout.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...