【发布时间】:2012-01-29 15:28:50
【问题描述】:
我正在编写我的多级导航元素,数据来自数据库。当我单击菜单项时,我想将参数传递给 APP_CONTROLLER,这对我来说会很神奇。
如何将 URL 参数传递给 APP_CONTROLLER 以具有影响所有控制器的功能?
网址:http://localhost/controller/function/id:5 或 http://localhost/controller/function/5
如果我尝试像这样在 APP_CONTROLLER 中获取参数
公共函数 beforeFilter() {
$id = $this->params['id']; } }
或
公共函数 beforeFilter($id) {
一些代码
}}
我会收到类似 Undefined index... 或 Missing argument 1 for AppController::beforeFilter()...
之类的错误消息我对 CakePHP 还很陌生,如何做到这一点?还是我有一些根本的设计缺陷?
// 贾里
【问题讨论】:
标签: cakephp-1.3