diff --git a/models/Comment.php b/models/Comment.php index 2463150..91d80a3 100644 --- a/models/Comment.php +++ b/models/Comment.php @@ -332,6 +332,21 @@ public function getOwnerModel() else $key = array_combine($primaryKey, explode('.', $this->owner_id)); $ownerModel = $this->owner_name; + + /* + * For using commentsWidget inside others modules + * we load model from module through 'modelAlias' param + * Example: + * 'commentableModels'=>array( + * //model with individual settings + * 'Blog' => array( + * 'modelAlias' => 'application.modules.blog.models.Blog', + * ), + * ), + * */ + $commentsModule = Yii::app()->getModule('comments'); + $config = $commentsModule->getModelConfig($ownerModel); + if (isset($config['modelAlias'])) Yii::import($config['modelAlias']); if(class_exists($ownerModel)) $this->_ownerModel = CActiveRecord::model($ownerModel)->findByPk($key); @@ -412,4 +427,4 @@ public function beforeSave() { return parent::beforeSave(); } -} \ No newline at end of file +}