hi bingomanatee,

thanks for you reply. I just found out that now you can directly call
element from the controller.

http://cakebaker.42dh.com/2007/12/21/rendering-elements-from-controllers/



On Dec 21, 10:18 am, bingomanatee <[EMAIL PROTECTED]> wrote:
> There are two simple ways to handle shared views. One is to simply
> specify the $this->view property within the handling methods.
>
> The other is to redirect from one method to another, with a specific
> flag. For instance, say you have a class Foo_controller with a view
> rss($edition) method and you want it to be overloaded with data from
> Bar_controller's rss($edition) method.
>
> class Foo_controller ... {
>
> ...
> function rss($edition)
> {
> $this->set('nodes', $this->Foo->getAllByEdition($edition);
> $this->redirect('/bars/rss/0/1');
> return;
>
> }
> } // end class
>
> class Bar_controller ... {
> ...
> function rss($edition, $from_foo = FALSE)
> {
> if (!$from_foo) $this->set('nodes', $this->Bar->getAllByEdition($edition); // 
> if $from_foo, data was already
>
> populated.
> $this->set('foo_or_bar', $from_foo ? 'Foo' : 'Bar'); // so the view
> will know what path to search for data inside nodes: $nodes[$i]
> [$foo_or_bar']['id'] and so on.
>
> }
> } // end class
>
> That way you always use the /bar/rss.thtml view, but its abstracted to
> be called from either controller.
>
> On Dec 21, 5:38 am, bingo <[EMAIL PROTECTED]> wrote:
>
>
>
> > hi,
>
> > I have a single RSS feed generator that can data from multiple
> > controller and generate the RSS. Currently I have it as an element and
> > for each controller class, I have a view that call this element to
> > generate the RSS feed. For instance.
>
> > I was wondering is there any way in cakePHP 1.2, that allows to share
> > same view across multiple controllers so I don't need to duplicate the
> > views that calls the RSS generator element. Something similar to $this-
>
> > >render but which can take any view or file path.
>
> > Looking at the core library, I realized there is an option to give a
> > file path in render function but not sure whether it is meant for this
> > only.
>
> > Regards,
> > Ritesh- Hide quoted text -
>
> - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to