1

I have added a new template file between cart page and checkout.The issue I am facing is that the content of the file is shown above the header please help me to solve this issue

public function linkAction()
{
$this->loadLayout();
$this->renderLayout();
echo $this->getLayout()->createBlock('core/template')->setTemplate('vatexempt/checkout/onepage/vatexempt.phtml')->toHtml();
}

This is how I call the template file in my controller.

Following is the code in my xmo file

<vatexempt_index_link> <!-- frontendname_controllername_actionname -->
    <reference name="content">
       <block type="core/template" name="vatexempt" template="vatexempt/checkou‌​t/onepage/vatexempt.phtml" />
    </reference>
</vatexempt_index_link>

Please Help me I am using magento 1.8 default theme

Pratik bhatt
  • 1,490
  • 13
  • 37

2 Answers2

1

You can make this change in layout.xml

<vatexempt_link_link translate="label">
    <label>link</label>
    <reference name="root">
        <action method="setTemplate"><template>page/1column.phtml</template></action>
    </reference>
    <reference name="content">
           <block type="core/template" name="vatexempt" template="vatexempt/vatexempt.phtml" />
    </reference>
    </vatexempt_link_link>

and set controller function as

public function linkAction()
{
$this->loadLayout();
$this->renderLayout();
}

This should work.

Milople Inc
  • 835
  • 2
  • 12
  • 33
0

The reason that there is output before the header is because you use:

echo $this->getLayout()->createBlock('core/template')->setTemplate('vatexempt/checkout/onepage/vatexempt.phtml')->toHtml();

You should change this to the following so that the content is added to the content section of your page:

$this->loadLayout()
            ->_addContent(
                $this->getLayout()
                    ->createBlock('core/template')->setTemplate('vatexempt/checkout/onepage/vatexempt.phtml')->toHtml()
            )
            ->renderLayout();
Vladimir Kerkhoff
  • 8,223
  • 1
  • 35
  • 41
  • I am getting following error Call to undefined method Indies_Vatexempt_LinkController::_addContent() in C:\wamp\www\vat\app\code\local\Indies\Vatexempt\controllers\LinkController.php on line 19 – Pratik bhatt Oct 16 '14 at 11:02