-1

I have a custom theme. In a controller is called a template from the custom theme, that overrides the default template:

$this->getLayout()->getBlock('root')->setTemplate('page/2columns-left.phtml'); 

But this 2columns-left.phtml is a wrapper template for almost every page of the website.

So, the template is located in frontend/mytheme/default/template/page/2columns-left.phtml and I copied the file and put it in frontend/mytheme/default/template/sparkasse/2columns-left.phtml where I did some changes on it, that I want to appear only for the page, called from that certain controller.

What I want is to call from that controller the changed template, that will override the custom template just for that page. But

$this->getLayout()->getBlock('root')->setTemplate('sparkasse/2columns-left.phtml'); 

does not render anything (white page). I guess I am missing some XML layout configuration or something, but I can't figure it out.

What I found was mostly about just overriding default templates with custom ones, which in my case is already done. I wanna go a step further.

UPDATE (being more specific):

The template from the custom theme, that overrides the default one, is used in every page.Then I call an action from my controller:

class SparkassenInternetkasse_Payment_PaymentController {
    public function redirectAction() {
            $this->loadLayout();
            $block = $this->getLayout()->createBlock('Mage_Core_Block_Template','SparkassenInternetkasse',array('template' => 'SparkassenInternetkasse_payment/redirect.phtml'));
            $this->getLayout()->getBlock('content')->append($block);
            $this->getLayout()->getBlock('root')->setTemplate('page/2columns-left.phtml'); 
            $this->renderLayout();
        }
...
}

and I am led to a page with URL: domain/SparkassenInternetkasse_payment/payment/redirect/

So, only and only in this page I want this wrapper template to be with some more changes made by me. My question is - how can I call it to be rendered? And what XML configuration (if needed) should I do?

0

Try putting your template in your base file to see if it has errors. If it renders, see if you have configured your theme properly and if it breaks anyway, you might have an error in the template.

  • I did change the general one with the changes that I want and it works fine. The template content is not the problem. The problem lays in connecting my overriding template with the system. – Syspect Aug 5 '14 at 11:34
0

In frontend/mytheme/default/layout/local.xml I added a new tag with name <router/controller/action> and inside I added <remove name="block_to_remove"> tags.

This did the job.

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.