Module configuration

I'd like to know, if I have to do the configuration of a module in it's module class?

For example:

class MyModule extends CWebModule

{

  private $_strUrl;

  public function init($config)

  {

    parent::init($config);

    $this->_strUrl = 'http://www.domain.com';

  }

  public function getUrl()

  {

    return $this->_strUrl;

  }

}

Why a module doesn't have a config.php file, to define some settings needed by the module?

Is the module class the place where all methods goes, which would be needed by controller class, i.e.:

class MyController extends CController

{

  public function actionIndex()

  {

    $strUrl = $this->module()->getUrl();

  }

}

is this the way to work with module class and controller?

thx

dan

You can configure your module easily with the following line in init():

$this->configure($configFile);

If you intend to reuse your module, then the module class is a good place to store module-level data, such as app component, parameters, etc. FYI, module and application share the same base class (as of version 1.0.4)

Quote

You can configure your module easily with the following line in init():

$this->configure($configFile);

If you intend to reuse your module, then the module class is a good place to store module-level data, such as app component, parameters, etc. FYI, module and application share the same base class (as of version 1.0.4)

ok, but if I do the following in the init function:

$this->configure(array('testVar' => 'testValue'));

how can I get the value of "testVar" in my controller?

UPDATE:

I've seen that I can access them as normal class members. But before I can do:

$this->configure(array('testVar' => 'testValue'));

I have do declare $testVar as member of the class. Is there any other way, to get configuration vars outside the controller class without declaring them all in the controller, for more flexibility?

Like application, a module also has params property which can hold module-level parameters. And you can access them using $controller->module->params[$paramName]

thanks for explain,

Max

bitumax

about modules, here are an usefuly toll;

http://www.yiiframew…pic,1363.0.html