CakePHP equivalent of requestAction() in Yii

Anybody aware of the CakePHP equivalent of requestAction.

In Yii, we have portlet but it is not the samething of requestAction() in cakephp where you can include any view in any view.

In yii you can just call the action directly (unless it's from another controller, which is more complicated).

In CakePHP, suppose we have an index and a post. In Index, we can do requestAction('post/5/') to include the no.5 post directly. I try renderPartial() like this, it does not seem to work.

I don't think this is good practice… you could theoretically do it in yii though, just directly set the GET variable, load the controller, then run the action (all manually, there is nothing magic).  I have not looked into how to load a controller that is not already active.

Widget? (a portlet is a custom sub-class of the widget BTW)

hi,

I was also wondering what the recommended way would be to be able to re-use a controller action that renders a view (but also has some kind of logic in it) in another controller.

thanks in advance

You could try Yii::app()->runController($route). However, this is not recommended. If you want to import the output of different controller actions into the portlets of the current page, it is better to call this in AJAX.

I have a similar issue and I solved it with a widget.

In my case I wanted a list of people to always appear on the left hand side.

I have a search action, to filter the list. When I reload the whole page I initially called the search action from within the view (bad practice).

Now I am using a list widget that uses session data. The search action only sets the search parameters in the session and then renders a view that uses the widget. The same widget is used in the view for the whole page.

Good to know that are solutions. I think it is a good idea to test something on the fly. In the long run, a widget or ajax solution should be more appropriate.