2012-05-10 2 views
1


하나의보기 '대시 보드'가있는 Yii 응용 프로그램에서 작업 중이며,이 단일 인터페이스에서 모든 응용 프로그램 작업을 수행해야합니다. 모든 사용자 세부 사항, 계정, 기록, 두부 기능으로 상태를 표시하는 것과 같습니다.어떻게 Yii에서 여러 모델을 사용하여 단일보기를 활발하게 만들었습니까?

--In Controller-- 
class DashboardController 
{ 
    public function actionDashboard() 
    { 
     $model = new MyDashboard; 
     if(isset($_POST['MyDashboard'])) 
     { 
      $this->model->save(); 
     } 
     $this->render('dashboard',array('model'=>$model)); 
    } 
} 


-- In Dashboard View -- 
// userd-details 
$this->widget('application.components.widgets.addGruopWidget.userdetails'); 

//account 
$this->widget('application.components.widgets.addGruopWidget.useraccount'); 

//user status 
$this->widget('application.components.widgets.addGruopWidget.userstatus'); 

//user history 
$this->widget('application.components.widgets.addGruopWidget.userhistory'); 

DashboardController를 사용하여이 '대시 보드'인터페이스에서 사용자의 모든 카드 활동을 정의하는 방법입니다. plz는 가능하면 해결책을 제안합니다. 감사 !!!

+0

쓴 글은 이미 작동 할 수 있지만 어쨌든 한 곳에서만 표시하면 꼭 위젯을 만들 필요가 없습니다. – marcovtwout

+0

넵, 그 한 곳이지만, 두부 시설 중 일부는 제대로 작동하지 않습니다. 단일보기에서 여러 모델로 여러 데이터를 게시합니다. 잘못되거나 구문이 잘못 될 수 있습니다. – Frank

답변

0
public function actionDashboard($action=null){ 

    if(!is_null($action) && strlen($action)>0){ 
    $method = "run".ucfirst($action); 
    if(method_exists($this,$method)){ 
     $this->$method(); // if $action is 'actionName' then $this->runActionName(); 
     Yii::app()->end(); 
    } 
    } 
} 


... 
} 


protected function runActionName(){ 
    /* dp something */ 
} 
관련 문제