Reputation: 959
I would like to know how I can make to get the url and the parameters in the view.
This code get the Controler name without the pamameters...
<?php echo $this->url(); ?>
Thanks you for your helping. Best regards,
Upvotes: 0
Views: 6992
Reputation: 21
A very late response in case it could help someone.
You can get request params in the view using :
$routeMatch = $this->getHelperPluginManager()->getServiceLocator()->get('Application')->getMvcEvent()->getRouteMatch()
$params = $this->getHelperPluginManager()->getServiceLocator()->get('Application')->getMvcEvent()->getRouteMatch()->getParams();
Upvotes: 2
Reputation: 1649
You can't get them easily from view script. You can however get them in Controller and pass it to view.
For simple paramaters you can use: $this->view->params = $this->getAllParams()
If you need something more, you need to ask Request object for it. To get Request object: $this->view->request = $this->getRequest()
. From now you can get all info from view by using eg. $this->request->getRequestUri()
Remember that you can use var_dump(get_class_methods($this->request))
to get list of all available methods.
Upvotes: 2
Reputation: 3329
Use following to get get url with parameter
$this->url('route', array('controller' => 'controller', 'action' => 'action', 'paramkey'=>'value'), array('force_canonical' => true))
Upvotes: 2