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 ...
随机推荐
- <转>详解DNS的常用记录(上):DNS系列之二
详解DNS的常用记录(上) 在上篇博文中,我们介绍了DNS服务器的体系结构,从中我们了解到如果我们希望注册一个域名,那么必须经过顶级域名服务器或其下级的域名服务器为我们申请的域名进行委派,把解析权委派 ...
- linux下配置双网卡及RAC规划——1
使用背景: 操作系统:centos 虚拟机:virtualbox RAC系统中需要双网卡,一个为公共的网络环境,一个为私有的网络环境,从而需要搭建双网络. 在菜单FILE中选择preferences, ...
- bzoj 2229 [Zjoi2011]最小割(分治+最小割)
[题目链接] http://www.lydsy.com/JudgeOnline/problem.php?id=2229 [题意] 回答若干个关于割不超过x的点对数目的询问. [思路] [最小割最多有n ...
- POJ 2280&&hdu 1661
题意:给定平面上的N个点,属性分别标记为0和1,然后找一条直线,直线上的点全部溶解,一侧的1溶解,另一侧的0溶解.求出最多能溶解的点的个数. 思路:暴力枚举每个点,扫描线旋转.先做优化,如果一侧溶解0 ...
- The solution to Force.Com IDE 29.0 PassWord Problem
我最近使用Force.com IDE 时,经常提示密码错误.从Google 中终于发现一个解决方法,分享给大家,以供大家参考. 在Force.com IDE 29.0中,IDE 存储我们开发Org ...
- hive优化之------控制hive任务中的map数和reduce数
一. 控制hive任务中的map数: 1. 通常情况下,作业会通过input的目录产生一个或者多个map任务. 主要的决定因素有: input的文件总个数,input的文件大小,集群设置的 ...
- android - python 自动化测试 移动互联网 - SegmentFault
android - python 自动化测试 移动互联网 - SegmentFault splinter
- (转载)JDOM/XPATH编程指南
JDOM/XPATH编程指南 本文分别介绍了 JDOM 和 XPATH,以及结合两者进行 XML 编程带来的好处. 前言 XML是一种优秀的数据打包和数据交换的形式,在当今XML大行于天下,如果没有听 ...
- DelphiXE7操作sqlite数据库
准备工作: 1.用SQLiteExpertPers建立一个sqlite数据库. 2.打开delphi xe7. 一.FireDAC法 设置库联接 1.放入FDConnection1控件 2.放入FDC ...
- 关于block以及__bridge的一些笔记
问题概要 _block是否是一个OC对象? __bridge相关. _block是否是一个OC对象? 结论 一般来说,block可以看做一个OC对象,但是在编译器底层,block又可以被细分为bloc ...