如果是 // 就會預設去調 protected/views/layouts,//代表 絕對路徑
其實 就是 絕對和相對的關系 /代表相對路徑,如module/user下的layout
用單斜杠的話預設會先找目前已經激活的子產品底下的view,若目前未有激活的子產品則從系統根目錄下開始找,雙斜杠的話就直接從系統根下開始找

$this->renderpartial('application.modules.admin.views.product._search')
yii framework已經定義的命名空間常量
system: 指向yii架構目錄; yii\framework
zii: 指向zii library 目錄; yii\framework\zii
application : 指向應用程式基本目錄; protected\
webroot: 指向包含裡入口腳本 檔案的目錄. 此别名自 1.0.3 版起生效. \
ext : 指向包含所有第三方擴充的目錄, 從版本 1.0.8 可用; \protected\extensions

yii::getpathofalias('zii')
yii::import ('zii.*')
yii::setpathofalias('backend', $backend);
'import' => array(
'backend.models.*',
應用的主目錄是指包含所有安全系數比較高的php代碼和資料的根目錄。在預設情況下,這個目錄一般是入口代碼所在目錄的一個目錄: protected 。這個路徑可以通過在application configuration裡設定 basepath來改變.
yii framework路徑

yii::getframeworkpath()
yii 檔案下載下傳

yii::app()->getrequest()->sendfile('test.txt', 'file content goes here.');
protected/runtime

yii::app()->getruntimepath();
protected/venders目錄

yii::import('application.venders.*');
或在protected/config/main.php說明

'import'=>array(
......
'application.venders.*',
),
插入meta資訊

yii::app()->clientscript->registermetatag('關鍵字','keywords');
yii::app()->clientscript->registermetatag('一些描述','description');
yii::app()->clientscript->registermetatag('作者','author');
yii::app()->clientscript->registermetatag(' text/html;charset=utf-8', null, 'content-type');
<link rel="alternate" type="application/rss+xml" href="http://www.dreamdu.com/feed/" />

yii::app()->clientscript->registerlinktag('alternate','application/rss+xml',$this->createurl('/feed'));

yii::app()->clientscript->registercssfile(yii::app()->baseurl.'/css/my.css');
yii::app()->clientscript->registerscriptfile(yii::app()->baseurl.'/css/my.js');
<?php echo $this->module->assetsurl; ?>/css/main.css
調用yii架構中framework/web/js/source的js,其中registercorescript key調用的檔案在framework/web/js/packages.php清單中可以檢視

yii::app()->clientscript->registercorescript('jquery');
在view中得到目前controller的id方法:

yii::app()->getcontroller()->id;
在view中得到目前action的id方法:

yii::app()->getcontroller()->getaction()->id;
yii擷取ip位址

yii::app()->request->userhostaddress;
yii判斷送出方式

yii::app()->request->ispostrequest isdeleterequest isajaxrequest
得到目前域名:

yii::app()->request->hostinfo
得到proteced目錄的實體路徑

yii::app()->basepath;
得到子產品名稱

$module = yii::app()->getmodule()->getid();
獲得上一頁的url以傳回

yii::app()->request->urlreferrer;
得到目前url

yii::app()->request->url;
得到目前home url

yii::app()->homeurl
得到目前return url

yii::app()->user->returnurl
項目路徑

dirname(yii::app()->basepath)
yii::app()->getbaseurl(true);
<?php echo $this->getlayoutfile('main'); ?>
$this->redirect('index.php?r=admin/manage');
{createurl()}

echo $this->createurl('urlboyleetest');
//out => /yii_lab/index.php?r=lab/urlboyleetest
$this->createurl('post/read') // /index.php/post/read

<?php echo yii::app()->request->baseurl; ?>/css/screen.css
yii::app()->theme->baseurl.'/images/filename.gif'
{createabsoluteurl()}

echo $this->createabsoluteurl('urlboyleetest');
//out => http://localhost/yii_lab/index.php?r=lab/urlboyleetest