Google pensa, che la questione è rilevante per ZF2 reindirizzare con ancora, così io aggiungerò la risposta qui, se non ti dispiace . Possiamo solo utilizzare fragment
opzione terzo argomento della toRoute
:
public function doAction(){
return $this->redirect()
->toRoute('chats',
array('action' => 'view',
'id' => $message->getChat()->getId()
),
array('fragment' => 'm' . $message->getId())
);
}
il mio percorso:
'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',
),
),
),
Così, l'utente sarà indirizzato smth come /chats/view/12/#m134
fonte
2015-04-30 13:04:23
Se stai reindirizzando, reindirizzare a un nome-percorso. Se vuoi semplicemente inviare un'altra azione, usa l'helper forward(). Vedi http://framework.zend.com/manual/2.1/en/modules/zend.mvc.plugins.html – Sam