I've created a series of partial views for a page in our Yii Framework site. Each partial view has it's own model because they call subsections of the main model class. Since each partial view has it's own model, do I need separate controller classes for each?
My loadModel portion of the User controller is as follows:
public function loadModel($id,$model_name='Users')
{
$model=Users::model()->findByPk($id);
if($model===null)
throw new CHttpException(404,'The requested page does not exist.');
return $model;
}
It is being called from this section of the User Controller:
public function actionProfile($id=''){
$user = Users::model()->find('username=:id', array
(':id' => Yii::app()->user->id));
if(!$id){
$id = $user->id;
if(!$id)
$this->redirect('login');
}
if( getUserSess('user_type') == 'Sitter') {
$this->render('profile_detail', array('user_id' => $id ));
} else {
$this->render('petowner_profile_detail',array(
'model'=>$this->loadModel($id),
));
}
}