Yii Framework Forum: returnUrl doesn't work in 1.0.0 - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

returnUrl doesn't work in 1.0.0 Rate Topic: -----

#1 User is offline   Yuest 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 8
  • Joined: 07-December 08
  • Location:China

Posted 07 December 2008 - 06:42 AM

i tried just unzip the source code and add a line <?php echo Yii::app()->user->returnUrl;?> into demos/hangman/protected/views/layouts/main.php,
then no matter what page i visit in the application, it always shows /yii/demos/hangman/index.php
0

#2 User is offline   Yuest 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 8
  • Joined: 07-December 08
  • Location:China

Posted 07 December 2008 - 06:55 AM

seems its my problem
i tried 1.0rc and it still doesn't work
but i remember it works fine before
i don't know what's wrong with my configuration
0

#3 User is online   qiang 

  • Yii Project Lead
  • Yii
  • Group: Yii Dev Team
  • Posts: 5,875
  • Joined: 04-October 08
  • Location:DC, USA

Posted 07 December 2008 - 07:21 AM

returnUrl is set by Yii when login is required. For the hangman demo, i won't be set unless you do it explicitly in the code.
0

#4 User is offline   Yuest 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 8
  • Joined: 07-December 08
  • Location:China

Posted 07 December 2008 - 07:32 AM

oh, i see
i should use Yii::app()->getRequest()->getUrlReferrer(), right?
0

#5 User is online   qiang 

  • Yii Project Lead
  • Yii
  • Group: Yii Dev Team
  • Posts: 5,875
  • Joined: 04-October 08
  • Location:DC, USA

Posted 07 December 2008 - 07:37 AM

I don't know your goal, but if you want to know the page referrer information, yes, it is.
0

#6 User is offline   tri 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 1,651
  • Joined: 20-November 08
  • Location:Stockholm, Sweden

Posted 07 December 2008 - 10:07 AM

Perhaps this is similar to my previous problem with the nice flag icons I put in the menu. When clicking one of those (to change application language) it turned out a simple refresh call would end up in a loop. I think referrer isn't used any more (nowadays)?

My solution was to save the previous url in the session object and restore it on reentering the controller. Maybe there is a better solution?

/Tommy

0

#7 User is online   qiang 

  • Yii Project Lead
  • Yii
  • Group: Yii Dev Team
  • Posts: 5,875
  • Joined: 04-October 08
  • Location:DC, USA

Posted 07 December 2008 - 10:27 AM

For your problem, returnUrl won't solve your problem because you need to set it BEFORE clicking the link.

You may consider using CHtml::linkButton to render the language menu item, like the following:

<?php echo CHtml::linkButton('button label', array(
    'submit'=>array('controllerID/actionID'),
    'params'=>array('url'=>Yii::app()->request->url),
)); ?>


Then, in the corresponding action, you will be able to know the current URL by $_POST['url'].
0

#8 User is offline   tri 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 1,651
  • Joined: 20-November 08
  • Location:Stockholm, Sweden

Posted 07 December 2008 - 01:15 PM

Quote

... You may consider using CHtml::linkButton ....


Thanks, that would be a less complicated solution. Maybe obvious to others, I learn everyday.  ;)

/Tommy

0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users