calling other controller actions

Hello everyone, I stumbled upon the same problem today.

So I wanted to call another controller’s action from within a controller.

After thinking of it for a while I thought I already solved this one with ajax.

So ajax call is one way to do it. But as others pointed out, try ajax calls only if there you want to create a form or if the user really does something, like a clicks or the press of a button.

The createController method works but you have to create a whole new function for it, and get into things that the framework should manage by itself. Don’t get me wrong, this proposals are positive feedback and should be encouraged in order to further develop Yii.

In our case I found that the most neat way to do it is the forward method.

The forward method is a that the controller forwards a new request to another controller and expects a response.

If you think about it, this is exactly what we would like to achieve.

So with a single line like this:


$this->forward("controller/action/GETparameterName1/GETparameterValue1/GETparameterName2/GETparameterValue2",false);

We get the response from this action. In my case is a renderPartial so this works great and there is no need for ajax.

I am not very experienced on widgets that’s why I haven’t used them. Maybe you could suggest a good tutorial.

I believe in situations like photos, where you use them all over the place in various situations, someone should propably create a widget with certain templates to do his job.

(to Yii developers: for one more time, I insist. each function should have an example, I spent, more time than I should to understand how ‘forward’ function works. Ok I’m a newbie but don’t you want more people on Yii?)

Yeap. Widgets’ the right thing.

By the way, symfony has a nice cms based on widgets, it’s called apostrophe.

Maybe we’ll migrate to symfony because of that.

Or we’ll success in creating just-another-cms, though it will be yii-and-widget-based.

Phundament and flexica are raw :(

Why do you need just-another-some-kind-of-universal CMS? Yii is a perfect tool for creating any kind of CMS (easy for regular users and with only functions they need). And the main advantage will be it’s extensibility.

We need it. We really do. A cms powerful like drupal or wordpress. And object-oriented like yii.