Minus-t
Minus-t

Reputation: 35

How to redirect in CakePHP with # in url, and not %23?

I am using CakePHP and I am doing this:

$this->redirect(array('controller' => 'users', 'action' => 'view',$id));

output in the browser: .../users/view/42

Since I am using JQueryUI tabs, I want the user to be redirected to the tab he just edited, so it should looks something like :

 $this->redirect(array('controller' => 'users', 'action' => 'view',$id."#groups"));

output in the browser: .../users/view/42%23groups

But expected result: .../users/view/42#groups

Q: How to send a correct url with #id in it to send the focus ?

I want, if possible, not use a custom GET param that echo a js in the view.ctp to get the focus asked.

I hope it is a CakePHP issue and don't need to change some .htaccess like (How to rewrite a URL with %23 in it?)

Upvotes: 1

Views: 3005

Answers (2)

Jaime Montoya
Jaime Montoya

Reputation: 7711

This is how I achieved it:

// Redirect to the home page.
$this->redirect(array(
    'controller' => 'cars',
    'action' => 'index',
    '#' => 'thankyou'
));

Upvotes: 0

mark
mark

Reputation: 21743

Please read the documentation http://book.cakephp.org/2.0/en/core-libraries/helpers/html.html#HtmlHelper::url

$this->redirect(array(
    'controller' => 'users', 'action' => 'view', $id, '#' => 'groups'));

Upvotes: 3

Related Questions