php - How load phtml of custom module in magento -



php - How load phtml of custom module in magento -

i need know how load phtml on custom module...

i need load phtml file on blocks...in magento

my code bellow.....i m creating module learning

purpose .....

what best way load phtml in custom block...

and if have model,controller other mvc...

then need of block in magento..

my controller ----------- class packt_new_indexcontroller extends mage_core_controller_front_action { public function indexaction() { echo "this new controller "; } public function newaction(){ $this->loadlayout(); $this->renderlayout(); } } 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> 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> block ------------------- class packt_new_block_newproducts extends mage_core_block_template { }

config.xml like

<layout> <updates> <unique_identifier module="yournamespace_test"> <file>yournamespace_test.xml</file> </unique_identifier> </updates> </layout>

app/design/frontend/default/default/layout/yournamespace_test.xml

<?xml version="1.0" encoding="utf-8"?> <layout version="0.1.0"> <catalog_category_view> <reference name="content"> <!-- block name within need display hello world --> <action method="settemplate"> <template>yournamespace_test/catalog/yournamespace_test.phtml</template> </action> </reference> </catalog_category_view> </layout>

more info go

php xml magento

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -