yii query string do not change when click language picker

谁说胖子不能爱 提交于 2019-12-12 03:53:31

问题


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

Example

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

It's all working fine...

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

How can i do this one?


回答1:


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

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

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>


来源:https://stackoverflow.com/questions/19605392/yii-query-string-do-not-change-when-click-language-picker

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!