Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CakePHP, GET Parameters and routing

I am fairly new to cakephp but I have a question relating to urls and parameters. I would like to be able to have a url that looks like a standard url e.g:

http://www.mysite.com/controller/myaction?arg=value&arg2=val

I would like that url to map to an action in my controller as follows:

function myaction($arg = null, $arg2 = null)
{
   // do work
}

I realize that cakephp has routing as described here, however, honestly this seems over engineered and results in a url string that is nonstandard.

In my current situation the url is being generated and invoked by an external (billing) system that knows nothing about cake and doesn't support the cake url format.

like image 321
Introgy Avatar asked Dec 18 '10 16:12

Introgy


1 Answers

You can have your URL in any form. It's just CakePHP allows you to retrieve the variable passed through GET from the variable $this->params['url']

function myaction()
{
  if(isset($this->params['url']['arg'])) 
    $arg = $this->params['url']['arg'];
  if(isset($this->params['url']['arg2']))
    $arg2 = $this->params['url']['arg2'];
}
like image 86
Sunny Avatar answered Sep 19 '22 23:09

Sunny