$this->request->data['Model']['field'];
$this->request->data('Model.field'); //キーが無い場合はnull
$this->data;
$this->request->query['page'];
Hash::get($this->request->query ,'page'); //キーが無い場合はnull
$this->params['url'];
$this->request->pass;
$this->request['pass'];
$this->request->params['pass'];
$this->params['pass'];
$this->passedArgs;
$this->request->named;
$this->request['named'];
$this->request->params['named'];
$this->params['named'];
$this->passedArgs;
class CategoriesController extends AppController {
function view($id, $other){}
}
Router::connect('/:controller/:action/*');
*
無しだとアクションは引数を取れません。*
が有ると複数の引数を取れます。
$id = '5';
$other = 'foo';
例えば example.com/categories/view/5/foo
にアクセスがあると、上記の様な値が入ります。
Router::connect('/cat/*', array('controller' => 'categories', 'action' => 'view'));
$id = '5';
$other = 'foo';
example.com/cat/5/foo
にアクセスがあると、上記の様な値が入ります。
Router::connect('/cat/:foo/:bar', array('controller' => 'categories', 'action' => 'view'), array('pass' => array('foo', 'bar'), 'foo' => '[0-9]+', 'bar' => '[a-z]{1,5}'));
アクションの引数に値を渡すにはRouter::connect()
の*
が必要ですが、このように設定する事も出来ます。この書き方だと、正規表現でのチェックが出来ます。