Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Symfony2 how do I redirect within a Controller to a URL with an anchor tag/hash

I'm in a Controller and I want to redirect back to a URL, say /home/news/example#comment1423

How can I add the hash in to the return params?

return $this->redirect(
    $this->generateUrl("news_view", array("permalink" => "example"))
);
like image 229
Elliot Coad Avatar asked Oct 11 '11 09:10

Elliot Coad


1 Answers

The simplest solution would probably be concatenation:

$url = $this->generateUrl("news_view", array("permalink" => "example"));
return $this->redirect(
    sprintf('%s#%s', $url, 'comment1423')
);
like image 150
kgilden Avatar answered Sep 27 '22 16:09

kgilden