How can I redirect to another module?
return $this->redirect()->toRoute(null, array(
\'module\' => \'othermodule\',
\'controller\' => \'s
Google thinks, that this question is relevant to zf2 redirect with anchor, so I will add the answer here, if you don't mind. We can just use fragment
option in third argument of toRoute
:
public function doAction(){
return $this->redirect()
->toRoute('chats',
array('action' => 'view',
'id' => $message->getChat()->getId()
),
array('fragment' => 'm' . $message->getId())
);
}
My route:
'chats' => array(
'type' => 'segment',
'options' => array(
'route' => '/chats/[:action/][:id/]',
'constraints' => array(
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
'id' => '[0-9]+',
),
'defaults' => array(
'controller' => 'Application\Controller\Chats',
'action' => 'index',
),
),
),
So, user will be directed to smth like /chats/view/12/#m134