How can I change the page template when viewing a certain category page?

So instead of the certain category page using page/1column.phtml, I'm trying to make it use a custom one, page\blah.phtml, and all other categories should still use page/1column.phtml.

I'm also wondering where I should put the following code, as I've tried putting it in a template file with no luck, I'm guessing it needs to go in a controller or a block PHP file, but I'm not sure which one.

$root = $this->getLayout()->getBlock('root');
$template = 'page/blah.phtml';

2 Answers 2


In the below example, I'm changing the view of Product Detail Page. So you can get the idea about it. Make sure to change parameters according to your need. Add below code in your layout file. If you're making custom module then it'll be on your custom module layout file. You can get below code in catalog.xml in your theme.

    <reference name="content"> 
 <block type="blah/blah" name="blah" template="page/blah.phtml" />  

For, the second query, it should be in controller.But, I don't think that code will be needed if you use the below code in controller.

 $this->loadLayout(); or // $this->loadLayout('root');

You can do this by layout handler ta magento

<reference name="root">
<action name="setTemplate">page/blah.phtml</action >

Suppose Category your category id is 75 then only for this category ,you can set page set template.

<reference name="root">
<action name="setTemplate">page/blah.phtml</action >
  • Thanks but where do I put that code? I have tried adding it to app/design/frontend/default/mysite/layout/page.xml but it didn't seem to work. Also is there a layout handle that can target all child categories (recursively) of a certain category?
    – Mex
    Commented Mar 26, 2015 at 12:56
  • @Mex See this extension I created: github.com/ProxiBlue/GlobalHandle which injects more handles into the layout. You should be able to adjust that fairly easily to inject a handle for a categories parent category, which will give you what you need.
    – ProxiBlue
    Commented Mar 26, 2015 at 15:15
  • @ProxiBlue Thanks, I have already solved my issue by using a different CSS class name on the body tag. I will bookmark your module, the event name you're using seems like the one I needed, as well as adding handles.
    – Mex
    Commented Mar 26, 2015 at 16:48

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.