Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion models/Comment.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -412,4 +427,4 @@ public function beforeSave() {
return parent::beforeSave();
}

}
}