If you want to dynamic management modules,you must need it.You can dynamically add modules with params.
Requirements ¶
Yii 1.1 or above
Usage ¶
[STEP1]
tar the module under protected/modules/moduleManage and modify the following to your main config
return array(
..............
'modules'=>include(dirname(__FILE__).DIRECTORY_SEPARATOR.'modules.php'),
..............
);
Done,you must add the modules.php in the config folder,and add the following to your modules.php
'moduleManage'=>array(
'moduleConfigFile'=>__FILE__//config the modules folder
),
Last,you should create a table with module_managel.sql. Now,you should configure the commpents of db ,and sure it to connect the db.and then,you visit the yourdomain/index.php?r=moduleManage.
[STEP2]
If step1 success ,now you can create a module. but before you create a module,you must use gii to generate the module's folder you want.if you complete it,you can click the create module tag,and write something to this form.It should be noted when you configure the module config,you must use PHP ARRAY Format,and you can use any key/value for it.
[STEP3] If step2 success,you can in your module to use these params ans status.For example:there is a testModule in my project,and open the module's config file (moduleName+Module.php)
class TestModule extends CWebModule
{
public function init()
{
//add hook
//default 'status' is reserved keyword you can get it by $this->params['status']
//you can get other cofing params by use $this->params[key]
// such as $this->params['maintain']
if($this->params['status']===0){
//do something here
}else{
//do something here
}
// this method is called when the module is being created
// you may place code here to customize the module or the application
// import the module-level models and components
$this->setImport(array(
'test.models.*',
'test.components.*',
));
}
}
geting error
while visiting /index.php?r=moduleManage.
got error
Invalid argument supplied for foreach()
public function setModules($modules)
{ foreach($modules as $id=>$module) {
getting error at this foreach.
It is from
/var/www/yii/framework/base/CModule.php(339)
want some clarification
In ModuleMangeModule.php
public $moduleConfigFile = '';
the variable is empty,is it required to give some path there?
how to write array format for config
pleas give some sample.
If you have any questions, please ask in the forum instead.
Signup or Login in order to comment.