how to redirect and add # in the end
Posted 14 April 2012 - 04:25 PM
Posted 14 April 2012 - 04:39 PM
sorry but i think you did not understand me
i have a website in one of my page i have a div with id="example"
now if i do something like <a href="www.mywebsite.com/projects/index#example" /> it works great
i want to do the same in yii so i tried:
and it not working
so how do i make a link in yii and add in the end the # symbol?
Posted 14 April 2012 - 05:01 PM
If you mean that you want to generate a link in your view that the user can then click on, which should include a hash, then that is a different question.
I haven't seen any parameters in createUrl for including a hash part, but at the very worst, in your view you would do something like
Posted 14 April 2012 - 05:14 PM
$url = Yii::app()->createUrl('projects/view', 'id' => $model->projectID)."#uniqe_$id";
should give you the same result, as well as allowing you to change your url scheme later without recoding if necessary (apart from the hash fragment of course).
And yes, I suppose if you are redirecting the url via a 302 code (not an invisible redirect), that should work - I hadn't though about it like that.
Posted 16 April 2012 - 06:52 AM
see this thread
Yii::app()->createUrl('projects/view', 'id' => $model->projectID, '#' => "#uniqe_$id");
Good to know - I hadn't come across that before.