Thursday, June 4, 2015

Magento -how to create layout of custom controller in magento

Magento -how to create layout of custom controller in magento

1. First create a controller. Suppose controller name is "test".
put this code here action name is "name".


<?php
class namespace_modulename_TestController extends Mage_Core_Controller_Front_Action{
public function nameAction()
{
    $this->loadLayout();  
   $this->renderLayout();
   
}
}
?>


2. After controller creation set layout go to design->template->layou open the xml file
put these code



<modulename_controllername_actionname> 
  <reference name="root">  
      <action method="setTemplate"><template>page/1column.phtml</template></action>  
    </reference>    
    <reference name="content">  
      <block type="core/template" name="getallcustomer_test" template="getallcustomer/test.phtml"/>  
    </reference>  
  </modulename_controllername_actionname>



3. and last send request for controller "modulname/controller/actionname".
print the all data of test.phtml file.

No comments :

Post a Comment