I was hesitant to reply yesterday as I haven't looked closely enough at the API or documentation to know if this would work, but...
Thinking it through, in my head, I thought perhaps you could add some code in the application's AppController in one of the specialty methods (afterRender?) to modify the values held in certain variables in the process. This is where searching through the API would come in - you'd need to know when and where $content_for_layout is passed to the main layout, and use one of the specialty methods available to controllers (in your AppController) to then update it with wrapping it all inside your sub-layout. The sublayouts (in my mind anyway, personal tastes may vary), since you want them to be controller specific, would simply be named after the controller -- controller.ctp -- and again depending on your implementation, would depend on where you stored the sub-layout view files. It's a theoretical, completely in my head, and I haven't looked at how it would be possible, but I'm absolutely certain it is. Keep in mind though, with controller-specific sub-layouts, you may have to also make controller-specific view variables (like, how to determine what goes in one column as opposed to another). That part I haven't really thought through, but from my "scripts_for_layout" topic in these groups, I'm sure it's possible. :) On Oct 9, 8:12 am, "Marc Campeau" <[EMAIL PROTECTED]> wrote: > Thanks for your time Adam. > > You're right that I could switch layouts but that's not what I was > looking for, I was trying to avoid putting switching logic in the > default layout, controller or views. I guess what I wanted to know is > if there's some kind of equivalency to ASP,Net Masterpages. The > concept of layout is similar but in Masterpages you get to define > Content Zones which are accessible by the other elements of the view, > which means that the view can output to a Zone of the layout. So you > could define a Masterpage to use by default that sets up your nav, > footer and cross-controller features. You would define zones whithin > this Masterpage. Now, since a Masterpage can depend on another > Masterpage, and views can depend on Masterpage you can use that chain > of dependency to load your general layout, then a controller specific > layout and finally a view where the view and controller specific > layout output to content zones defined in the Masterpages. > > I don't think that Cake Layouts support that type of behavior. > > Thanks again, spelling it out made me see the situation more clearly, > > Marc > > 2008/10/9 Adam Royle <[EMAIL PROTECTED]>: > > > > > > > Is it possible for you to create multiple layouts and set var $layout > > = "alternate" in your controller? > > > You could share headers and footers etc between the layouts by using > > elements. > > > It's also possible to change the layout dynamically in your view, or > > set variables for your layout from inside the view. > > > Hope that gives you some ideas. > > > Cheers, > > Adam > > > On Oct 9, 1:53 am, Marc Campeau <[EMAIL PROTECTED]> wrote: > >> Hi all, > > >> I've been wondering if it is possible to use sub-layouts with my > >> views. Let me explain what I mean by "sub-layout": > > >> I've got a layout/default.ctp setup to display header, content and > >> footer for the whole website. The body part is just a big div where > >> all the controller/action views are rendered. Now, I would like to use > >> a sub-layout within the content zone that, this sub-layout is > >> controller specific, for instance I have a controller that needs to be > >> rendered using a two column layout and another one with three columns > >> regardless of the action being performed by the controller. > > >> I don't want to duplicate the controller specific layout to all the > >> different controller/action views which is why I'm thinking a sub > >> layout would be appropriate, rather than elements. > > >> Here's what I want to achieve: > >> In default.ctp: > >> ---- > >> header code layout > >> begin content code layout > >> $content_for_layout > >> end > >> footer code layout > > >> Where $content_for_layout is such that: > >> --- > >> begin controller specific layout > >> view controller/action > >> end > > >> Do I make sense? Am I splitting hairs? Is it possible? How should I go > >> about this? > > >> Thanks for your input, > > >> Marc- Hide quoted text - > > - Show quoted text - --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---