Re: Switch Element On/Off
Determine the business logic in the controller and use controller-set to communicate the decisions to the views/elements. Don't get too hung up on strict seperation of M-V-C there's plenty of grey across the boundaries... A pragmatic approach if generally more productive :) Interesting discussion here: http://groups.google.com/group/cake-php/browse_thread/thread/7786024149ca244b/efeb2a04e537e6b1?lnk=gstq=stutchbury+viewrnum=1#efeb2a04e537e6b1 ~GreyCells On Feb 28, 7:44 pm, phirschybar [EMAIL PROTECTED] wrote: Hey all.. What if I have an element and I want to switch it on for some pages and off for others? I could easily pass it some data and do the logic to determine if it should be shown right within the element itself or even in the default layout but then I would have business logic right in the views, violating MVC... How can I do the logic in the controller where it should be and only call the element from there? --~--~-~--~~~---~--~~ 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: Switch Element On/Off
Make multiple layouts and switch between them in the controller, $this- layout = 'no_thingy'; On Feb 28, 11:44 am, phirschybar [EMAIL PROTECTED] wrote: Hey all.. What if I have an element and I want to switch it on for some pages and off for others? I could easily pass it some data and do the logic to determine if it should be shown right within the element itself or even in the default layout but then I would have business logic right in the views, violating MVC... How can I do the logic in the controller where it should be and only call the element from there? --~--~-~--~~~---~--~~ 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: Switch Element On/Off
scragz: that sounds silly unless there is a slick way of doing 'includes' with parts of layouts. In your case I would be repeating a lot of layout code. GreyCells: thats exactly what I ended up doing. In my controller, I set a boolean and then just did a simple check for it in the view before rendering the element. I guess I could have also rendered the element and did the check inside of that but why bother including an extra file on every hit.. right? Thanks for the advice, guys. Ben On Feb 28, 4:01 pm, GreyCells [EMAIL PROTECTED] wrote: Determine the business logic in the controller and use controller-set to communicate the decisions to the views/elements. Don't get too hung up on strict seperation of M-V-C there's plenty of grey across the boundaries... A pragmatic approach if generally more productive :) Interesting discussion here: http://groups.google.com/group/cake-php/browse_thread/thread/77860241... ~GreyCells On Feb 28, 7:44 pm, phirschybar [EMAIL PROTECTED] wrote: Hey all.. What if I have an element and I want to switch it on for some pages and off for others? I could easily pass it some data and do the logic to determine if it should be shown right within the element itself or even in the default layout but then I would have business logic right in the views, violating MVC... How can I do the logic in the controller where it should be and only call the element from there? --~--~-~--~~~---~--~~ 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: Switch Element On/Off
Includes with parts of layouts are elements. Other way is probably better though. On Feb 28, 1:49 pm, phirschybar [EMAIL PROTECTED] wrote: scragz: that sounds silly unless there is a slick way of doing 'includes' with parts of layouts. In your case I would be repeating a lot of layout code. GreyCells: thats exactly what I ended up doing. In my controller, I set a boolean and then just did a simple check for it in the view before rendering the element. I guess I could have also rendered the element and did the check inside of that but why bother including an extra file on every hit.. right? Thanks for the advice, guys. Ben On Feb 28, 4:01 pm, GreyCells [EMAIL PROTECTED] wrote: Determine the business logic in the controller and use controller-set to communicate the decisions to the views/elements. Don't get too hung up on strict seperation of M-V-C there's plenty of grey across the boundaries... A pragmatic approach if generally more productive :) Interesting discussion here: http://groups.google.com/group/cake-php/browse_thread/thread/77860241... ~GreyCells On Feb 28, 7:44 pm, phirschybar [EMAIL PROTECTED] wrote: Hey all.. What if I have an element and I want to switch it on for some pages and off for others? I could easily pass it some data and do the logic to determine if it should be shown right within the element itself or even in the default layout but then I would have business logic right in the views, violating MVC... How can I do the logic in the controller where it should be and only call the element from there? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---