Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.


Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, biapar, Willr, Ingo, simon_w

How to change $Layout theme?

Go to End

10 Posts   4561 Views


15 May 2008 at 6:15pm Community Member, 8 Posts

Hi all,

i thinking how to change $Layout theme from page controller, now $Layout depends on page type and associated template with it(in Layout dir), but lets say i have two Page type pages and want that the $Layout would be rendered with different themes. How can I do that? Is it possible?


8 October 2008 at 5:16pm Community Member, 105 Posts

I also have a similar question I would like to swap the layout from the controller as I understand $controller::renderWith("TemplateName"); will swap the whole template, I would like to know if there is a way to keep the current template and only swap the $layout portion from the controller?


8 October 2008 at 6:08pm Community Member, 105 Posts

Okay figured it out $controller::renderWith(array("LayoutTemplate", "PageTemplate"));

Basically by passing the Layout template then the Page template it will render in the correct order.


8 October 2008 at 8:01pm Forum Moderator, 921 Posts

So you'd want change the Layout template, without creating a new page type?

It makes sense. We also have a ticket in our open source tracker to allow choosing of a layout template from the CMS. So, you could create templates like Page_twocols, Page_threecols, Page_wide, Page_narrow, Page_alternative or anything you'd like, and you can choose any of those templates using a dropdown on each page, which defaults to just "Page", of course.

Here's the ticket if you want to see: [url][/url]



8 October 2008 at 8:20pm Community Member, 105 Posts

Yes exactly. That sounds good Typo3 has a similar thing and sub pages will inherit their parents temple which is also useful.


9 October 2008 at 2:10am Community Member, 87 Posts

I have the same problem, I don't know where is the file to modify $controller::renderWith(array("LayoutTemplate", "PageTemplate"));

I have an othe question: if I use ticket how cai I use this? I read guide but I don't understand if is possible to download thicket..


9 October 2008 at 8:39am Forum Moderator, 921 Posts

Sorry, I wasn't clear.

That's a ticket for the functionality to be added. It means that someone came up with the idea, and we just added it to the tickets for someone to create the functionality at a later date.

Until then, you can just use the method that CodeGuerrilla has shown.

CodeGuerrilla, did you put your renderWith() method inside the Page_Controller init() method?


9 October 2008 at 12:29pm Community Member, 105 Posts

No, I was calling it via another method of the controller:

function archive()
   return self::renderWith(array("NewsArchive", "Page"));

Basically will use the layout file but will still use the main template works well, with the exception of the Breadcrumbs :)

Go to Top