1

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?)

2 Answers 2

3

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'));
3
  • Just after posted this Q, I found the awnser at: stackoverflow.com/questions/8615516/… In my case it is: $this->redirect(array('controller' => 'users', 'action' => 'view',$id,'#' =>"groups")); (i was searching for '#' in suggested questions title, not 'hashtag', but I have not enought reputation to awnser my own question...)
    – Minus-t
    May 29, 2013 at 9:42
  • As already mentioned above you would have found the answer reading the official documentation.
    – mark
    May 29, 2013 at 9:48
  • I have the cakephp doc tab pinned, but I don't know why this time I searched first on the web without finding; I came here.
    – Minus-t
    May 29, 2013 at 9:52
0

This is how I achieved it:

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

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.