YII 路径总结
来源:互联网 发布:网络视频赌博骗局 编辑:程序博客网 时间:2024/06/10 22:49
如果是 // 就会默认去调 protected/views/layouts,//代表 绝对路径
其实 就是 绝对和相对的关系 /代表相对路径,如module/user下的layout
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()
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'));
如何在控制器添加CSS文件或JavaScript文件
- 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
得到当前域名:
- Yii::app()->request->hostInfo
得到proteced目录的物理路径
- YII::app()->basePath;
获得上一页的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
- yii 路径 总结
- YII 路径总结
- Yii路径总结
- YII 路径总结
- YII 路径总结
- YII路径的用法总结
- YII路径的用法总结
- YII路径的用法总结
- Yii中的常用路径总结 [ 1.1 版本 ]
- Yii 路径
- yii路径
- Yii路径
- Yii 路径
- yii总结
- yii中常用路径
- yii中常用路径
- Yii中常用路径
- yii中常用路径
- 拆解4G发牌六大爆点:为td-LTE开路
- jena 简单查询2(推理)
- win7 64bit系统 搭建jdk1.7、Myeclipse10.、tomcat7.0
- cocos2d-x封神榜(1) -- 【研发思路及感想】
- 编译错误:configure: error: newly created file is older than distributed files!
- YII 路径总结
- 陌陌:蛋疼,移动社交真心不好做!
- dom4j xpath 语法
- [Unity] 文件夹图像资源的读取
- Win8页面之间传值练习
- Eclipse中修改包名或类名
- SD销售凭证改号码段
- 异步下载图片
- 查看solaris系统的版本和位数