Magento – How load phtml of custom module in magento with block on controller

blockslayoutmagento-1.8template

I need to know how to load phtml on custom module…

I need to load phtml file on my blocks…in magento

my code is bellow…..I m creating module for my learning

purpose …..

what is the best way to load phtml in custom block…

And if I have model,controller like other mvc…

then what is the need of block in magento..

my controller
-----------
class Packt_New_IndexController extends Mage_Core_Controller_Front_Action
{
public function indexAction()
{
echo "this is my new controller ";
}
    public function newAction(){

        $this->loadLayout();
        $this->renderLayout();

    }


}

my config.xml
----------------
<?xml version="1.0" encoding="UTF-8" ?>
<config>
    <!-- module configuration -->
    <modules>
        <Packt_New>
            <version>0.0.1</version>
        </Packt_New>
    </modules>
    <!-- module configuration end -->
    <global>
        <blocks>
            <new>
                <class>Packt_New_Block</class>
            </new>
         </blocks>
         <helpers>
            <new>
                <class>Packt_New_Helper</class>
            </new> 
        </helpers>
        <models>
            <new>
                <class>Packt_New_Model </class>
            </new>
        </models>
    </global>
    <frontend>
        <routers>
            <new>
                <use>standard</use>
                <args>
                    <module>Packt_New</module>
                    <frontName>new</frontName>  
                </args>
            </new>
        </routers>
        <layout>
        <updates>
            <new>
                <file>new.xml</file>
            </new>
        </updates>
        </layout>
    </frontend>

</config>


my layout.xml
---------------------
<?xml version="1.0" encoding="UTF-8"?>
<layout>
   <!-- <default>
        <remove name="header"/>
    </default>-->
    <new_index_new>
        <refrence name="root">
            <action method="setTemplate">
                <template>page/2columns-right.phtml</template>
            </action>
        </refrence>
        <refrence name="content">
            <block type="new/newproducts" name="block_newproducts" template="new/new.phtml"></block>
        </refrence>
    </new_index_new>
</layout>

this is my block
-------------------
class Packt_New_Block_Newproducts extends Mage_Core_Block_Template
{



}

Best Answer

You have added the block block_newproducts into content but is this being called somewhere?

In your content phtml you should output the block with

echo $this->getChildHtml('block_newproducts');