参考:http://book.cakephp.org/cn/view/541/Named-parameters
New in CakePHP 1.2 is the ability to use named parameters. You can name parameters and send their values using the URL. A request for /posts/view/title:first+post/category:general would result in a call to the view() action of the PostsController. In that action, you’d find the values of the title and category parameters inside $this->passedArgs[‘title’] and $this->passedArgs[‘category’] respectively.
新的cakephp1.2中你可以在URL中使用名字作为参数,请求 ‘/posts/view/title:first+post/category:general’ 会自动调用PostsController中view()方法,在此action中包含了title和category的值,通过 $this->passedArgs[‘title’]和$this->passedArgs[‘category’] 来访问。
URL to controller action mapping using default routes:
默认路由下URL到控制器和Action的映射:
URL: /monkeys/jump
Mapping: MonkeysController->jump();
URL: /products
Mapping: ProductsController->index();
URL: /tasks/view/45
Mapping: TasksController->view(45);
URL: /donations/view/recent/2001
Mapping: DonationsController->view('recent', '2001');
URL: /contents/view/chapter:models/section:associations
Mapping: ContentsController->view();
$this->passedArgs['chapter'] = 'models';
$this->passedArgs['section'] = 'associations';
没有评论:
发表评论