Dynamic actions


I was wondering if anyone had any experience with an extension that can load certain contact from an action, Without registering the action ID in the controller actions() method?

Basically what i want to do in my action is to render a JS like the following:

<script src='http://domain.com/actionID'></script>

Where actionID stands for the following array:



'class' => 'application.extensions.MyExtAction',

'property1' => 'value1',



Problem is that i sometimes call that extension or a widget that uses that extension inside a view, So the request was already handled. I assume i can add an event that will add the required actions to the currently viewed controller but i was wondering if there is any other way. Eventually i would like to avoid editing controller file to add actions that the extension uses, Specially when there can be lots of actions and can be placed in any controller.


Correct me if I’m wrong, but what you want is to insert the following code in your view

$url = CHtml::normalizeUrl($myAction);

Yii::app()->getClientScript()->registerScriptFile($url, CClientScript::POS_HEAD);

when the action “$myAction” isn’t yet declared in the controller?

I suggest that your widget should create an ActionProvider class. Then each controller could add it to its actions. See actions doc.

That’s the issue, I do not want to modify each controller to add the action to the actions array by overriding the actions method. And the registerScript was just an example, it can be any thing else that an action can do. like rendering, returning, etc…