0

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)?

rockstar
  • 1,322
  • 1
  • 20
  • 37

1 Answers1

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