重寫actions
'help'=>array(
'class'=>'CViewAction',
'basePath'=>'help', //指定目錄名
'defaultView'=>'default',
'viewParam'=>'help' //get參數(shù)
),
假定當(dāng)前控制器是post
那么可以能過/post/help/help/content訪問help目錄下的content.php
可以建立子目錄比如help/reigterhelp/content.那可以通過/post/help/help/registerhelp.content來訪問
用CViewAction的好處時,可以與其它的view共享layout
關(guān)于沒有權(quán)限訪問跳轉(zhuǎn)的url相關(guān)
當(dāng)沒有權(quán)限時調(diào)用CAccessControlFilter類中的accessDenied,其調(diào)用CwebUser中的loginRequired(),記錄當(dāng)前的returnurl后跳轉(zhuǎn)到
CWebUser配置中的loginurl,在此處登陸后,可以通過redirect跳轉(zhuǎn)到returnurl(Yii::app()->request->redirect(Yii::app()->user->returnUrl);)
當(dāng)強(qiáng)制顯示登陸表單,比如判斷用戶是guest就一直列出登陸表單,不會調(diào)用loginRequired, 就得不到returnurl,這時候想跳回去,參見
cookbook上相關(guān)貼子
registerCoreScript
在framework/web/js/package.php中列出的才是
多對多關(guān)聯(lián)條件
$criteria->addInCondition("categorys.id",$in);
$criteria->addSearchCondition('Shop.name',$keyword);
$shops=Shop::model()->with(array("categorys"=>array('together'=>true)))->findAll($criteria);
同時要在Shop模型中加入alias="categorys" ,另外together=true放在模型的關(guān)聯(lián)中也可
YII中的RBAC權(quán)限,用數(shù)據(jù)庫存item,