Um..... I practically rolled on the floor when I saw the one-liner that did what you wanted..... The method I gave was a case of using shot-gun to kill a fly.....(w.r.t the case in view) That method allows you to create reusable elements in cake. Consider for example that you want to have a sidebar on your site. And you want it to show up depending on what page you're on. then since more than one controller and action would be using this same 'element', alongside their own separate views. Use elements if you want to create dynamic sidebars. Another way of looking at it is that assuming you would like to display some text/title/form based on the action you call - viewx /viewall using the one-liner might(actually will) make things complicated,, the better way to do this is to create elements, and display things based on the context. Those, I think are the benefits I've noticed using elements damo wrote: thanks for your replies. I will probably just go with the simple render option as this seems ridiculously easy to do! What would be the benefit of using the (slightly) more complicated elements option?I am also trying to figure out how to modify multiple records with a single form. I see that there has been a ticket open and closed on this topic which requires patching of some of the config files. Is this still the only way of achieving this? On Apr 16, 8:05 pm, TechSteve <[EMAIL PROTECTED]> wrote:vote for this way. Femi Taiwo's method is perfect, but for simple use, if you just have these two actions to be rendered in the same view, easier way will be better in my mind. On Apr 16, 2:19 am, grigri <[EMAIL PROTECTED]> wrote:function viewx() { $this->set('students', ...); $this->render('viewall');}On Apr 16, 6:52 am, damo <[EMAIL PROTECTED]> wrote:Can't seem to figure this one out.I have two controllers that I would like to use the same view for. Here is how they are:function viewall() { $this->set('students', $this->Student->findAll(array( 'Student.status' => "Active" )));}function viewx() { $this->set('students', $this->Student->findAll(array( 'Student.status' => "Active",'Student.state' != "X"))); }What do I have to add to the 'viewx' to get it to render in the same view as the viewall?Many thanks Damo --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~--- |
- single view for multiple controllers damo
- Re: single view for multiple controllers Femi Taiwo
- Re: single view for multiple controllers grigri
- Re: single view for multiple controllers TechSteve
- Re: single view for multiple controllers damo
- Re: single view for multiple controllers Femi Taiwo
- Re: single view for multiple controllers Sourabh Sharma