I want to call show.phtml file which will print database records from entry.phtml file.Here is the code of my files having-


 echo "<pre>";



<form enctype="multipart/form-data" method="post" action="<?php echo $this->getBaseUrl().'entry/index/save' ?>">
    <input type="text" name="name" placeholder="Enter Name">
    <input type="text" name="email" placeholder="Enter Email">
    <input type="text" name="mobile" placeholder="Enter Mobile">
    <input type="submit" value="Enter">


3 Answers 3


You can call your phtml file in another phtml file as below

<?php echo $this->getLayout()->createBlock('core/template')->setTemplate('module-folder-name/show.phtml')->toHtml() ?> 

But if you want to show your phtml file from controller as you commented below my answer, you can call it as below.

Create a phtml file


 echo "<pre>";


Create an xml file


<?xml version="1.0"?>   
<layout version="0.1.0">   
    <reference name="root">   
      <action method="setTemplate"><template>page/1column.phtml</template></action>   
    <reference name="content">   
      <block type="module/index" name="module_index" template="module/show.phtml"/>   

Create a controller file


class Vendor_Module_IndexController extends Mage_Core_Controller_Front_Action{
    public function IndexAction() {


  • it works ,but open show.phtml file on same page. how to open show.phtml file in new tab ?
    – Akshay10
    Commented Oct 9, 2017 at 6:17
  • so what do you want exactly ? Commented Oct 9, 2017 at 6:22
  • to create a new function (showAction) in indexController and open show.phtml file, using controller function .
    – Akshay10
    Commented Oct 9, 2017 at 6:25
  • See my updated code. I have used IndexAction. You can use it as you want. Commented Oct 9, 2017 at 6:40

Place the bellow code where you want to call your file:

<?php echo $this->getLayout()->createBlock('core/template')->setTemplate('path/to/show.phtml')->toHtml() ?> 
  • Actually he needs to show his phtml file by using controller action. Commented Oct 9, 2017 at 8:01

To call .phtml file through controller:

try this code--

public function showAction()

    $block = $this->getLayout()->createBlock('core/template');

    // Assign your template to it
    // This path is relative to your current theme (eg: rwd/default/template/...)

    // Render the template to the browser
    echo $block->toHtml();


in your main template(.phtml file) write this code:

<a href="<?php echo $this->geturl("entry/index/show"); ?>">Show</a>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.