2012-05-10 8 views
1


Yiiアプリケーションでは、1つのビュー( 'ダッシュボード')しかないので、私はこの単一のインターフェイスですべてのアプリケーションアクティビティを実行する必要があります。すべてのユーザーの詳細、アカウント、履歴、curd機能によるステータスを表示するのと同じです。どのようにYiiで複数のモデルを使用して単一のビューをwigetized?

--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を使用して、この単一の「Dashboard」インターフェースですべてのカードアクティビティを定義する方法です。可能であれば、plzは解決策を提案します。ありがとう!!!

+0

あなたが書いたことはすでに機能している可能性がありますが、ウィジェットを作成する必要はありません。 – marcovtwout

+0

うん、その1つの場所、しかしいくつかのカード機能が正しく動作しない場合は、私たちは単一のビューから複数のデータを複数のモデルに投稿します。間違っているか構文違反になっている可能性があります。 – 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 */ 
} 
関連する問題