Re: problem with switching layouts
Thanks for pointing out my error. It works now. Thanks again. On Jun 18, 6:01 pm, "Chris Hartjes" <[EMAIL PROTECTED]> wrote: > On 6/18/07, sushil <[EMAIL PROTECTED]> wrote: > > > > > > > Hi All, > > I have again come across a problem. I have static page (rendered by > > pages controller) - loginbox and I have a layout for it. > > > While running the application, if a session is set, then the app will > > run else a login box is to be displayed. For the login box, there is > > different layout (loginbox.thtml). The code to change layout is: > > -- > > if($this->name ='Pages') > > { > > if($this->action = 'loginbox') > > { > > $this->layout = 'loginbox'; > > } > > } > > else > > $this->layout = 'default'; > > - > > I'm hoping it's a typo in you code, but shouldn't it say: > > if ($this->name == 'Pages') > > -- > Chris Hartjes > > My motto for 2007: "Just build it, damnit!" > > @TheBallpark -http://www.littlehart.net/attheballpark > @TheKeyboard -http://www.littlehart.net/atthekeyboard --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" 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 -~--~~~~--~~--~--~---
Re: problem with switching layouts
On 6/18/07, sushil <[EMAIL PROTECTED]> wrote: > > Hi All, > I have again come across a problem. I have static page (rendered by > pages controller) - loginbox and I have a layout for it. > > While running the application, if a session is set, then the app will > run else a login box is to be displayed. For the login box, there is > different layout (loginbox.thtml). The code to change layout is: > -- > if($this->name ='Pages') > { > if($this->action = 'loginbox') > { > $this->layout = 'loginbox'; > } > } > else > $this->layout = 'default'; > - I'm hoping it's a typo in you code, but shouldn't it say: if ($this->name == 'Pages') -- Chris Hartjes My motto for 2007: "Just build it, damnit!" @TheBallpark - http://www.littlehart.net/attheballpark @TheKeyboard - http://www.littlehart.net/atthekeyboard --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" 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 -~--~~~~--~~--~--~---
problem with switching layouts
Hi All, I have again come across a problem. I have static page (rendered by pages controller) - loginbox and I have a layout for it. While running the application, if a session is set, then the app will run else a login box is to be displayed. For the login box, there is different layout (loginbox.thtml). The code to change layout is: -- if($this->name ='Pages') { if($this->action = 'loginbox') { $this->layout = 'loginbox'; } } else $this->layout = 'default'; - This works fine. The problem is, the layout doesn't change back to the default layout if there is an active session. Can you guys help me on this? Regards, Sushil --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" 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 -~--~~~~--~~--~--~---
Re: Switching Layouts
Mark Quinn ha scritto: > my view contains >$this->controller->set( 'cheese', 'cheddar' ); > $cheese = 'brie'; > ?> put this in your controller: $this->set('cheese','padano'); --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" 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 -~--~~~~--~~--~--~---
Re: Switching Layouts
On 7/31/06, lorenzo <[EMAIL PROTECTED]> wrote: > > nate ha scritto: > > > but that's controller code. You should, however, still be able to use > > $this->layout in your view templates. > Sure ... but is better in controller than in view ;) > I've just been using layout = 'other_layout'; ?> which works just fine. My current problem is how to get a view to set a variable that is available in the layout. From everything i've read. this should be easy, but i'm just not getting any loving. I baked a trivial example: my layout contains my favourite cheese is my view contains controller->set( 'cheese', 'cheddar' ); $cheese = 'brie'; ?> but the variable always comes out blank. Can anyone help? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" 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 -~--~~~~--~~--~--~---
Re: Switching Layouts
nate ha scritto: > but that's controller code. You should, however, still be able to use > $this->layout in your view templates. Sure ... but is better in controller than in view ;) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" 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 -~--~~~~--~~--~--~---
Re: Switching Layouts
Actually it'd be more like this: if ($this->Session->check('layout')) { $this->layout = $this->Session->read('layout'); } but that's controller code. You should, however, still be able to use $this->layout in your view templates. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" 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 -~--~~~~--~~--~--~---
Re: Switching Layouts
kdbdallas ha scritto: > OK, I am hoping this is my last question, but no promises. :-) > > How do I tell a view in my controller to use a different layout. > In my layouts DIR I have default.thtml and secondary.thtml. > What do I put in the controller file to specifiy which layout to use? > you can store choice in a session: function BeforeFilter() { $this->layout = $_SESSION['layout']; } --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" 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 -~--~~~~--~~--~--~---
Re: Switching Layouts
Minor correction; that should be var $layout = layout; ;-) Ryan --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" 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 -~--~~~~--~~--~--~---
Re: Switching Layouts
kdbdallas wrote: > I figured it out. > > Thanks all > > > $this->render(view, layout); if you want to use the same layout for all the views of the controller you can also use ar $layout = layout; --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" 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 -~--~~~~--~~--~--~---
Re: Switching Layouts
I figured it out. Thanks all $this->render(view, layout); --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" 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 -~--~~~~--~~--~--~---
Switching Layouts
OK, I am hoping this is my last question, but no promises. :-) How do I tell a view in my controller to use a different layout. In my layouts DIR I have default.thtml and secondary.thtml. What do I put in the controller file to specifiy which layout to use? Thanks!!! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" 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 -~--~~~~--~~--~--~---
Re: PagesController switching layouts
thanks for the replys, for static pages I used AD7six example --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" 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 -~--~~~~--~~--~--~---
Re: PagesController switching layouts
Hi saavedrajj, copy the pages controller from cake/libs/controller to /app/controller if you haven't already. In the pages display method, use whatever logic you like to determine if the layout should change, and set the layout variable. e.g. // START EDIT. After the page variable has been determined change the layout if needed. if ($page=="special") // /app/views/pages/special.thtml { $this->layout = 'wierd'; // /app/views/layouts/wired.thtml } // END EDIT. $this->set('page', $page); // etc. And off you go... cheers, AD7six --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" 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 -~--~~~~--~~--~--~---
Re: PagesController switching layouts
Okay, any files you put in /app/views/layouts can be used as layouts in your controller. So let's say you have default.thtml and new.thtml (note the extension), and they're stored in the layouts/ folder. In your controller, you can put: $this->layout = 'new'; to switch which layout is used to render the page. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" 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 -~--~~~~--~~--~--~---
PagesController switching layouts
I need to use at least 2 different layouts in my static pages at cake/app/views/pages How can I do this? I dont't understand this thread: http://groups.google.com/group/cake-php/browse_thread/thread/84314667706d38ca/e12788ee919633e8 Thanks --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" 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 -~--~~~~--~~--~--~---