blakcaps
blakcaps

Reputation: 2647

Magento Module Block Not Working

I am creating a custom module in magento.I have created block class and phtml file.But localhost/dev/index.php/testimonials/index/index is not showing the block?Any ideas?

Output should be "block loaded".Instead i get this http://imageshack.us/photo/my-images/525/screenshotvs.png/

UPDATE

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

this code works under default handle.But its not working in <testimonials_index_index>

Here is the code

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

Block Class

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

Layout file

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

Upvotes: 1

Views: 3611

Answers (3)

Schenn
Schenn

Reputation: 58

Your versioning is incorrect as well. Be sure that your module versions are the same in each xml file.

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

Upvotes: 0

blakcaps
blakcaps

Reputation: 2647

Correct code is

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

Upvotes: 2

Nasaralla
Nasaralla

Reputation: 1839

You need to define a controller IndexController with IndexAction and do a loadLayout and renderLayout.

Upvotes: 0

Related Questions