I currently have url like localhost/zend_practice/countries/index?data=1 where countries is the name of my controller and index is name of my action. I would like to have url like localhost/zend_practice/countries/index/data/1. Also a rule to accept numbers only for the get parameter 'data'. How can i do this for 'countries' controller only (not for my other controller)?
Asked
Active
Viewed 349 times
0
-
1rtfm: [The Standard Router](http://framework.zend.com/manual/en/zend.controller.router.html) – prodigitalson Jun 29 '12 at 03:20
-
are getting this URL with form submission? – Zuber Surya Jun 29 '12 at 05:48
1 Answers
0
Zend Framework by default takes url as
/controller/action/parameter_name/parameter_value
You can directly use your url as
/countries/index/data/1
and in the code you can get the data parameter and apply your logic as required. Here's a snippet.
class CountriesController extends Zend_Controller_Action{
public function indexAction(){
//capture the data parameter
$data = $this->_request->getParam('data');
//check data if numeric
if(is_numeric($data)){
//your code goes here....
}
}
}

tashi
- 782
- 6
- 5