17488 Posts in 4473 Topics by 1978 members
| Go to End | Next > | |
| Author | Topic: | 3958 Views |
-
How to change $Layout theme?

15 May 2008 at 6:15pm
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?
-
Re: How to change $Layout theme?

8 October 2008 at 5:16pm
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?
-
Re: How to change $Layout theme?

8 October 2008 at 6:08pm
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.
-
Re: How to change $Layout theme?

8 October 2008 at 8:01pm
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: http://open.silverstripe.com/ticket/2791
Sean
-
Re: How to change $Layout theme?

8 October 2008 at 8:20pm
Yes exactly. That sounds good Typo3 has a similar thing and sub pages will inherit their parents temple which is also useful.
-
Re: How to change $Layout theme?

9 October 2008 at 2:10am
HI!
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 http://open.silverstripe.com/ticket/2791 how cai I use this? I read guide but I don't understand if is possible to download thicket..
-
Re: How to change $Layout theme?

9 October 2008 at 8:39am
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?
-
Re: How to change $Layout theme?

9 October 2008 at 12:29pm
No, I was calling it via another method of the controller:
function archive()
{
return self::renderWith(array("NewsArchive", "Page"));
}Basically will use the NewsArchive.ss layout file but will still use the main Page.ss template works well, with the exception of the Breadcrumbs
| 3958 Views | ||
| Go to Top | Next > |



