I'm using
$this->redirect('route', array('id' => $id));
but I need to be able to put "#" anchor at the end but I can't find a way of doing that. Any ideas?
The code
$this->redirect('route', array('id' => $id));
returns /route/id/5 but I want to be able to create /route/id/5#anchor7
EDIT - Solution found
Ok figured out a solution. Its working fine :)
$this->redirect($this->generateUrl('route', array('id' => $id)) . '#anchor7');
StackOverflow wouldn't let me post it as an answer since I'm a "new user" O_o
Source: Tips4all, CCNA FINAL EXAM
Your own answer:
ReplyDelete$this->redirect($this->generateUrl('route', array('id' => $id)) . '#anchor7');
not tested, but:
ReplyDelete$this->redirect('route', array('id' => ($id.'#anchor7'));
Another (hacky) way:
Add a field to your parameters, e.g. 'anchor' => 'anchor7' and on the target site, parse this parameter and use javascript to scroll to the anchor.