I'm reforming an extension into a module, to get rid of the controllerMap stuff in config, and because… well it feels like a module.
In there is a widget, used several times on the same page. To exclude the use of the same db fragment, I filled in the extension a defined value: Yii::app()->controllerMap['vote']['context']
Was kinda hoping that I could use Yii::app()->controller->module->context for the same purpose, but it seems that no parameter is available for a module widget.
Any idea how to tackle this?
Aahh… should pay attention to docs…: Yii::app()->modules['moduleID'] gives the array. Only thing left: How to read module parameters?
CWebModule has most properties that an application has. That means, it can have its own set of params, components, controllerMap, etc. Please check its API for more details.
Okay, let me rephrase the question. Is there a way to use getParams() and setParams() on the params of a module in a widget, or do I need to define and use controllerMap or application-level params for this?
Sorry, can't seem to get it working. Perhaps I'm doing something completely wrong. I have a module, that module contains a widget, extended from CWidget.
This widget is used in normal (non-module) views. In the widget I can read initial property values with: Yii::app()->modules['moduleID']['propertyID'], but can't set them. I have 'params' defined under the module, like an initial property value. So I can read it, but can't set it in the widget.
But $controller->module->params turns up empty. $this->owner will show the controllerID of the view, not the module.
Application params can be read with Yii::app()->params (and set with Yii::app()->setParams) just fine.
Since there is no setParams for module params, it's probably not possible to set them anyway?