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

2 Answers 2

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.

0
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();
1
  • 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 Oct 16, 2014 at 11:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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