This behavior can create URLs that allow to return to a page by storing its GET Parameters on a stack.
The extension evolved from this forum discussion. Please add any comments or bug reports there.
protected/extensionsCreate an URL that contains all the GET parameter of the current page:
echo CHtml::link('A link', $this->createReturnableUrl('user/edit',array('id'=>124)) );
If you perform an action on the page user/edit you can use this code to return to the originating page:
$this->goBack()
or create a link to the originating page in the view with:
echo CHtml::link('Cancel',$this->getReturnUrl())
See the included demo for a more extensive example.
This project is hosted on github.
Total 7 comments
@schmunk Done :)
Could you put it on github?
Yep, works fine now!
Thanks, i've updated the extension. Could you test it please?
The extension does not support urls going to modules. For instance when going from "controllerA/actionA" to "module/controllerB/actionB" and returning, it returns to "module/controllerA/actionA". The solution is simple: just replace "$this->getOwner()->createUrl" everywhere in the extension component by "Yii::app()->createUrl".
When using path url format I've got 404 error from web server.
My sollution: add urldecode and urlencode to urlCompress and Uncompress
public static function urlCompress($data) { return urlencode(base64_encode(addslashes(gzcompress(serialize($data),9)))); } public static function urlUncompress($data) { return unserialize(gzuncompress(stripslashes(base64_decode(urldecode($data))))); }how to install xReturnable
Leave a comment
Please login to leave your comment.