Under module "group" i need group object for all controllers, then i have
GroupModule.php
public function beforeControllerAction($controller, $action)
{
if(parent::beforeControllerAction($controller, $action))
{
// this method is called before any module controller action is performed
// you may place customized code here
//Si tenemos grupo obtenerlo
if ($_GET['idgroup']){
$this->setParams(array('group' => XGroup::model()->findByPk($_GET['idgroup'])));
}
return true;
}
else
return false;
}
And in every controller under module group i have:
class ForumController extends Controller
{
public function actionIndex()
{
$forum = $this->module->params->group->forum;
$forum_categories = $forum->categories;
$this->render('/group/forum/index', array('forum' => $forum, 'forum_categories' => $forum_categories));
}
public function actionView()
{
$forum = $this->module->params->group->forum;
$this->render('/group/forum/view', array('forum' => $forum));
}
...
}
In the views i use $this->module->params->group for show group’s data.
is this correct?