Helpers\URL
Helpers\URL
The URL class is used for having handy methods or redirecting the page and returning the path to the current template.
Redirect - To redirect to another page instead of using a header call the static method redirect:
Url::redirect('path/to/go');
Previous - To be redirected back to the previous page:
Url::previous();
The redirect method can accept a 2nd option of true is used the path will be used as it is provided.
This is useful to redirect to an external website, by default the redirects are relative to the domain its on.
The url should be the local path excluding the application url for instance a valid case might be:
Url::redirect('contacts');
The redirect method uses the DIR constant to get the application address.
template_path has been renamed to templatePath
The next method is get_templatePath, this returns the path to the template relative from the templates folder, for instance by default it will return: http://www.example.com/templates/default/ this is useful for using absolute paths in your design files such as including css and js files.
Url::templatePath();
autolink has been renamed to autoLink
Another useful feature is the ability to scan a block of text look for any domain names then convert them into html links. To use the autoLink call url:: followed by the method name and pass in the string to autoLink:
$string = "A random piece of text that contains google.com a domain.";
echo Url::autoLink($string);
The autoLink method also accepts a 2nd parameter that will be used as the click text for instance a in the text above I want the link to say Google and not google.com.
$string = "A random piece of text that contains google.com a domain.";
echo Url::autoLink($string, 'Google');
When run the link word will be Google which will link to http://google.com
Helpers\URL的更多相关文章
- Yii URL
参考文章: http://blog.csdn.net/iefreer/article/details/21325371 以http://localhost/basic/web/index.php?r= ...
- YII框架路由和URL生成
路由和URL生成 当一个YII应用开始处理一个请求的时候,它首先要做的便是将请求的URL转化成一个路由.路由的作用是用于后续实例化相应的控制器和操作,以便处理请求,整个处理过程便叫做路由.路由的逆过程 ...
- Yii的URL助手
Url 帮助类 获得通用 URL 记住 URLs 检查相对 URLs Url 帮助类提供一系列的静态方法来帮助管理 URL. 获得通用 URL 有两种获取通用 URLS 的方法 :当前请求的 home ...
- YIi url美化
一.Yii Url美化,配置urlManager组件 'urlManager' => [ 'enablePrettyUrl' => true, // 开启URL美化,可以去掉 index. ...
- yii的url写法
Yii 各种url地址写法 echo Url::home(); 生成入口地址/yii2test/frontend/web/index.php: echo Url::base();生成入口文件夹地址: ...
- Yii 各种url地址写法
echo Url::home(); 生成入口地址/yii2test/frontend/web/index.php: echo Url::base();生成入口文件夹地址:/yii2test/fron ...
- yii2.0中url重写实现方法
在yii框架里有前台和后台页面,举例前台url重写. 控制器与路由 控制器以Controller作为后缀,继承自yii\web\Controller; 动作以action作为前缀,public访问修饰 ...
- 使用Typescript重构axios(三)——实现基础功能:处理get请求url参数
0. 系列文章 1.使用Typescript重构axios(一)--写在最前面 2.使用Typescript重构axios(二)--项目起手,跑通流程 3.使用Typescript重构axios(三) ...
- yii2的分页和ajax分页
要想使用Yii分页类第一步:在控制器层加载分页类 use yii\data\Pagination;第二步: 使用model层查询数据,并用分分页,限制每页的显示条数$data = User::find ...
随机推荐
- MongoDB@入门一
安装MongoDB自行搜索, 我这里提供GUI版本类似navicat. 1. 数据库层面 show dbs #查看服务器上的数据库 [local 0.000GB] use test #切换到指定 ...
- JSON2 源代码
/* json2.js 2014-02-04 Public Domain. NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK. See ht ...
- JAVA中的数据结构——集合类(线性表:Vector、Stack、LinkedList、set接口;键值对:Hashtable、Map接口<HashMap类、TreeMap类>)
Java的集合可以分为两种,第一种是以数组为代表的线性表,基类是Collection:第二种是以Hashtable为代表的键值对. ... 线性表,基类是Collection: 数组类: person ...
- HDU-4749 Parade Show KMP算法 | DP
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4749 题意:给两个串S和P,求S串中存在多少个与P串的大小关系一样的串. 因为数字的范围是1<= ...
- coco2d-x 纹理研究
转自:http://blog.csdn.net/qq51931373/article/details/9119161 1.通常情况下用PVR格式的文件来进行图片显示的时候,在运行速度和内存消耗方面都要 ...
- Git 一些日常使用积累
本来不想写这样的东西的,因为随处谷歌百度都有一大堆!但是,我却总是在百度谷歌,我在想,为什么我不自己写一篇存进来,顺便加深印象呢?既然这样,这篇随笔,就真的变成随笔好了,随时修改,随时添加. Git ...
- HDU 1856 More is better(并查集)
http://acm.hdu.edu.cn/showproblem.php?pid=1856 More is better Time Limit: 5000/1000 MS (Java/Others) ...
- AVCaptureDevice LED闪光灯控制
转载自:http://blog.csdn.net/cloudhsu/article/details/7202368 #import <AVFoundation/AVFoundation.h> ...
- [HDU 4089]Activation[概率DP]
题意: 有n个人排队等着在官网上激活游戏.Tomato排在第m个. 对于队列中的第一个人.有以下情况: 1.激活失败,留在队列中等待下一次激活(概率为p1) 2.失去连接,出队列,然后排在队列的最后( ...
- win8图片默认不显示
最近,发现了一个问题,在查看图片的时候,出现了这样的情况: 查看的时候很不方便,想要找到自己需要的图片就要误打误撞,也不知道自己在哪儿设置了,于是,上网查资料,才发现其实只需要简单的该一下设置就可以了 ...