Reputation: 29
Only pass the two parameter of controlle in action?
Upvotes: 2
Views: 22765
Reputation: 901
In the view create link.
echo $this->Html->link('',array('controller'=>'Vehicles','action'=>'deleteimage',$param1,$param2),array('confirm'=>'Are you sure you want to delete the image?'));
In the above link I have sent two parameters to deleteimage
function of the Vehicles
controller.
In controller access the parameters by public function deleteimage($id, $image)
Upvotes: 6
Reputation: 6571
mysite.com/myController/myAction/param1/param2
in controller:
function myAction($arg1,$arg2)
{...}
Upvotes: 16
Reputation: 1238
You can use named parameters, like this:
example.com/controller/action/param1:value/param2:value
In this canse you will find 'param1' and 'param2' in your controller in $this->passedArgs.
You can also define a custom route:
Router::connect('/news/:date/:article_name/:id',
array('controller'=>'articles', 'action'=>'view'),
array('pass' => array('id'), 'id'=>'[\d]+')
);
In this case, the action view in ArticlesController will be called with 'id' as the argument (and the route will only be matched if id passes the check for only containing digits). You can then also access 'date' and 'article_name' in the variable $this->params.
Upvotes: 4