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的更多相关文章

  1. Yii URL

    参考文章: http://blog.csdn.net/iefreer/article/details/21325371 以http://localhost/basic/web/index.php?r= ...

  2. YII框架路由和URL生成

    路由和URL生成 当一个YII应用开始处理一个请求的时候,它首先要做的便是将请求的URL转化成一个路由.路由的作用是用于后续实例化相应的控制器和操作,以便处理请求,整个处理过程便叫做路由.路由的逆过程 ...

  3. Yii的URL助手

    Url 帮助类 获得通用 URL 记住 URLs 检查相对 URLs Url 帮助类提供一系列的静态方法来帮助管理 URL. 获得通用 URL 有两种获取通用 URLS 的方法 :当前请求的 home ...

  4. YIi url美化

    一.Yii Url美化,配置urlManager组件 'urlManager' => [ 'enablePrettyUrl' => true, // 开启URL美化,可以去掉 index. ...

  5. yii的url写法

    Yii 各种url地址写法 echo Url::home(); 生成入口地址/yii2test/frontend/web/index.php: echo  Url::base();生成入口文件夹地址: ...

  6. Yii 各种url地址写法

    echo Url::home(); 生成入口地址/yii2test/frontend/web/index.php: echo  Url::base();生成入口文件夹地址:/yii2test/fron ...

  7. yii2.0中url重写实现方法

    在yii框架里有前台和后台页面,举例前台url重写. 控制器与路由 控制器以Controller作为后缀,继承自yii\web\Controller; 动作以action作为前缀,public访问修饰 ...

  8. 使用Typescript重构axios(三)——实现基础功能:处理get请求url参数

    0. 系列文章 1.使用Typescript重构axios(一)--写在最前面 2.使用Typescript重构axios(二)--项目起手,跑通流程 3.使用Typescript重构axios(三) ...

  9. yii2的分页和ajax分页

    要想使用Yii分页类第一步:在控制器层加载分页类 use yii\data\Pagination;第二步: 使用model层查询数据,并用分分页,限制每页的显示条数$data = User::find ...

随机推荐

  1. 利用Javascript获取当前日期的农历日期

    来源:http://www.ido321.com/926.html JavaScript代码 1: /*设置农历日期*/ 2: var CalendarData=new Array(100); 3: ...

  2. CSS框模型(框模型概述、内边距、边框、外边距、外边距合并)

    CSS 框模型概述 CSS 框模型 (Box Model) 规定了元素框处理元素内容.内边距.边框 和 外边距 的方式. 元素框的最内部分是实际的内容,直接包围内容的是内边距.内边距呈现了元素的背景. ...

  3. ArcMap10.1修改要素属性字段

    ArcMap10.1修改要素属性字段 问题描述:在ArcMap10.1中编辑要素属性表时,遇到输入字段值的长度超过字段最大长度时,ArcMap会抛出“基础DBMS错误[ORA-12899:value ...

  4. Windows server 2008 上部署 MVC (NopCommerce 3.4)网站

    自己用开源框架做了个商城,该框架是基于mvc4的,本地编译通过,运行一切正常,关于发布遇到了好几个问题. 本地: IIS7.5. VS2013 总结后发现只需要设置两个问题,就不会有那些古怪的问题:什 ...

  5. linux网络编程笔记——UDP

    目前这部分代码会出现阻塞问题,暂时尚未解决 #include "udp.h" #include <stdio.h> #include <string.h> ...

  6. 激活Windows 10

    激活Windows 10按 win+X 组合键,打开“命令提示符(管理员)”,输入以下代码:slmgr /ipk NKJFK-GPHP7-G8C3J-P6JXR-HQRJR  然后按Enter键回车即 ...

  7. 用MATLAB实现字符串分割

    strsplit更好用,用法: strsplit(strtrim(sprintf('  \t\nds   \nhs\t dssd    \t    \n'))) 以下转载 Matlab的字符串处理没有 ...

  8. 怎样提交FIREDAC数据集的DELTA到中间件然后保存进数据库

    你可以在客户端序列FireDAC数据集的DELTA , 将序列后的STREAM发送给中间件, 中间件的TFDQuery或TFDMemTable调用LOADFROMSTREAM()方法加载流, 然后调用 ...

  9. 网络子系统53_ip协议分片重组_内存阈值

    //调用路径:ip_defrag->ip_evictor // 分片重组时,可使用内存上下限: // 1.sysctl_ipfrag_high_thresh 可用内存上限 // 2.sysctl ...

  10. 网络子系统54_ip协议分片重组_定位ipq

    //为分片确定正确的ipq结构 // 定位5元组 // 1.<id, 源ip, 目的ip, l4协议> 可通过ip报文获取 // 2.user 通过ip_defrag给出,指出重组是由谁发 ...