div
div

Reputation: 17

cakephp 2.4: pass value instead of id in url?

I m new to cakephp, want to know how can i change url like this

C:/xyz.com/countries/view/5 to C:/xyz.com/countries/ABC

where 5 is id of ABC country

Thanks in Advance

Upvotes: 1

Views: 1034

Answers (1)

cornelb
cornelb

Reputation: 6066

Router::connect('/countries/:country_id', array('controller' => 'countries', 'action' => 'view'), array('pass' => array('country_id')));

In the controller:

public function view() {
   $countryId =  $this->request->params['country_id'];
}

Upvotes: 1

Related Questions