我该如何重定向到另一个模块?
return $this->redirect()->toRoute(null, array(
'module' => 'othermodule',
'controller' => 'somecontroller',
'action' => 'someaction'
));
这似乎不起作用,有什么想法吗?
我该如何重定向到另一个模块?
return $this->redirect()->toRoute(null, array(
'module' => 'othermodule',
'controller' => 'somecontroller',
'action' => 'someaction'
));
这似乎不起作用,有什么想法吗?
这是我如何从控制器重定向到另一个路由的方法:
return $this->redirect()->toRoute('dns-search', array(
'companyid' => $this->params()->fromRoute('companyid')
));
其中dns-search是我想要重定向的路由,companyid是url参数。
最终URL变为/dns/search/1(例如)
重定向的一种简单方法是:
return $this->redirect()->toUrl('YOUR_URL');
return $this->redirect()->toUrl('/make-world-easy?id=thank-you');
- user285594This is the way of redirection in ZF2:
return $this->redirect()->toRoute('ModuleName',
array('controller'=>$controllerName,
'action' => $actionName,
'params' =>$params));
ModuleName
应该改为 RouteName
。 - Lukas IgnatavičiustoRoute
的第三个参数中使用 fragment
选项:public function doAction(){
return $this->redirect()
->toRoute('chats',
array('action' => 'view',
'id' => $message->getChat()->getId()
),
array('fragment' => 'm' . $message->getId())
);
}
'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',
),
),
),
/chats/view/12/#m134
的页面。