yii查询字符串在单击语言选择器时不会更改 [英] yii query string do not change when click language picker

查看:104
本文介绍了yii查询字符串在单击语言选择器时不会更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

实际上,我的网站具有语言选择器,它的工作原理不错,但有人为我的Web应用程序提供了重定向网址.

Actually My web having language picker, its working nice but some one give redirect url for my webapp.

示例

http://yii.mywebapp.com/?redirecturl=http://www.google.com

一切正常...

但是,当点击语言选择器时,网址将为

But when click language picker the url will be

http://yii.mywebapp.com/?language=en

但是我需要不完全更改网址,我只需要按照以下方式填写完整的网址

But i need the url not fully changed, i need only the full url following way

http://yii.mywebapp.com/?redirectUtl=http://google.com&language=en

我该怎么办?

推荐答案

我假设您只是想保留URL中的所有GET参数,并向其中添加language参数.

I assume you simply want to preserve all GET parameters in the URL and simply add the language parameter to it.

Yii请求对象具有称为,它将以字符串形式返回当前可用的所有参数.

The Yii Request object has a method called getQueryString() which will return all parameters currently available as a String.

您可以对上面发布的示例代码执行以下操作,以创建语言选择器URL:

Using that you could do the following to the example code you posted above to create your language picker URL:

<?php
$getParams = Yii::app()->request->getQueryString();
// ... 
?>
<!-- ... -->
<a href="<?php echo $baseURL . (empty($getParams) ? '?' : '&amp;' ); ?>language=fr">…</a>

这篇关于yii查询字符串在单击语言选择器时不会更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆