如果是 // 就会默认去调 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