returnUrl doesn't work in 1.0.0

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

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

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.

oh, i see

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

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

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

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'].

Quote

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

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

/Tommy