activeform佈局
findAll等不能知足where, order by, limit,底層調用了findByCondition
col-md col-lg的使用php
view的方法,前三個經常使用
render 把變量傳遞給頁面,頁面結果做爲content變量傳遞給佈局文件
renderPartial 只生成view文件,不使用佈局文件
renderAjax
renderContent 將變量傳遞到佈局文件
renderFile 編譯php或其餘文件
renderPartial和renderContent相結合等於render
文件路徑指定方式:別名@app完整路徑,//當前app起路徑,/當前module的views起路徑,viewcontextinterface返回的view(只有view名字如about,此種居多),getViewFile上次render使用的view文件目錄(兩次連續使用render,render的頁面中再使用render)css
controller的render實際調用了view的render函數,view的render不用調用佈局文件app
view中註冊css等:css等在文件開頭,js有POS_HEAD(head結束標籤前),POS_BEGIN(body開始標籤後),POS_END(body結束標籤前),POS_LOAD(JQuery標籤中),yii
POS_READY幾種;文件前後順序
$this->registerMetaTag()
$this->registerLinkTag($options)
$this->registerCss($css)代碼
$this->registerCssFile($url)文件
$this->registerJs($js)
$this->registerJsFile($url)
asset bundle函數
生成順序:meta link css js
css、js文件 的depends佈局
controller定義了佈局變量$layout
module裏面定義了佈局變量$layout
先查看當前controller裏面有沒有定義佈局變量,沒有則查找所在module裏面定義的佈局變量,尚未則查找父級module定義的佈局變量
指定佈局文件:false(不使用),null(用module中的),字符串(指定文件,別名方式、/開頭、當前module中定義的)
佈局文件的結果能夠繼續傳遞給另外一個佈局文件(beginContent)this
向佈局文件傳遞多個變量(yii自己只能傳遞一個)
view中,lulucms/widgets/InhritLayout
$this->beginBlock('content1')
....
$this->endBlock()
$this->beginBlock('content2')
....
$this->endBlock()
佈局文件就能夠使用變量$content一、$content2顯示他們中間的內容url
controller傳遞變量方式:orm
1 render時一併傳入:render("about",['var'=>'value'])
2 賦值給view對象
$view=\Yii::$app->getView()
$view->params['var']='value'
3 view對象中
$context = $this->context;
context即爲controller,佈局文件中也能夠
widget中context爲view對象