Reputation:
My url is as below
domain.com/admin/delete/1/2/3
I want to get last value 1 2 and 3 in different variable.
may be like segment
delete($arg1,$arg2,$arg3){ }
OR
$param = getallparam();
Please any one let me know how can I achieve this in zend framework. My zf version is 1.12
Upvotes: 1
Views: 478
Reputation: 13843
What you're looking for is custom routing. When you initialize the application, you can add something like the following to your FrontController:
$front = Zend_Controller_Front::getInstance();
$front->setParam('useDefaultControllerAlways', false);
$front->setControllerDirectory('application/controllers');
$front->getRouter()->addRoute('mycontrol', new Zend_Controller_Router_Route('/action/:param1/:param2/:param3', array(
'controller' => 'mycontrol',
'module' => 'default',
'action' => 'action',
'param1' => ''),
'param2' => ''),
'param3' => ''))
);
Then, in your controller (i.e. in MycontrolController->actionAction()) you can access the parameters as
$param1 = $this->_request->getParam('param1', $default = '');
$param2 = $this->_request->getParam('param2', $default = '');
$param3 = $this->_request->getParam('param3', $default = '');
Upvotes: 1
Reputation: 2377
You can achieve it in this way Update your url as
domain.com/admin/delete/str1/1/str2/2/str3/3
now use code
echo "<pre>";
print_r($this->_request->getParams());
echo "</pre>";
Upvotes: 0