tags:

views:

32

answers:

2

Only pass the two parameter of controlle in action?

+4  A: 
mysite.com/myController/myAction/param1/param2

in controller:

function myAction(arg1,arg2)
{...}
Leo
your answer is good but pass two argument in deferant link..like i am click the edit link to pass only one parameter( eg. edit_id) and click add link pass another parameter (eg .add_id)
ChiragPatel
That's basic cake. Read the book and study the examples!
Leo
+1  A: 

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.

Oscar