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 ...
随机推荐
- linux 用 SSH2协议远程连接并控制 linux
[参考链接](http://php.net/manual/zh/ssh2.installation.php) ssh2_exec 并不能打印所有的命令的提示信息 如果有返回的字符串信息,可以打印,或重 ...
- python学习之self,cls,staticmethod,classmethod
一.总体说明 python类里会出现这三个单词,self和cls都可以用别的单词代替,类的方法有三种, 一是通过def定义的 普通的一般的,需要至少传递一个参数,一般用self,这样的方法必须通过一个 ...
- php里面为什么header之前有输出报错 源码分析
众所周知,php 里面 header之前有输出的话,会报错,例如下面这样 就这个错误,我们开始查阅php源代码,到底是怎样做的,至于php源代码分析,安装,和调试时怎样配置的,我会专门写一篇文章去 ...
- Standalone HBase
This is the default mode. Standalone mode is what is described in the quickstart section. In standal ...
- [Hive - Tutorial] Querying and Inserting Data 查询和插入数据
Querying and Inserting Data Simple Query Partition Based Query Joins Aggregations Multi Table/File I ...
- thymeleaf中的条件判断用法
一.简单的条件:“if”和“unless” th:if用法实例: <table> <tr> <th>NAME</th> <th>PRICE& ...
- [iOS基础控件 - 6.11.2] - UINavigationController 多控制器 简单使用
A.概念 1.通常一个app有多个控制器 2.需要对这些控制器进行管理 3.有多个view的时候,用一个父view去管理多个子view 4.控制器管理也是如此,使用给一个父控制器,去控制子控制器 ...
- [iOS基础控件 - 6.10.7] UIWindow
A.UIWindow概念 1.继承UIView,是一种特殊的UIView 2.通常一个APP只有一个UIWindow 3.iOS程序启动后,创建的第一个视图就是UIWindow 4.没有UIWindo ...
- IP访问SQL数据库设置
http://wenku.baidu.com/link?url=mnjuPMo9qJvzluCHEvqVDawpuloKeGla05a2L3UtqzD_bF1VJMb7jHY4SBhuYH3-K_xF ...
- VC的文件操作
各种关于文件的操作在程序设计中是十分常见,如果能对其各种操作都了如指掌,就可以根据实际情况找到最佳的解决方案,从而在较短的时间内编写出高效的代码,因而熟练的掌握文件操作是十分重要的.本文将对Visua ...