CakePHP htmlhelper链接方法忽略了请求URL的id参数

CakePHP htmlhelper链接方法忽略了请求URL的id参数,cakephp,html-helper,Cakephp,Html Helper,我的视图包含一个用于更改页面语言的链接。索引、添加页面都很好。但是当涉及到“编辑”或“查看”页面时,如果在URL的末尾有一个ID号,那么这个数字在这个链接上不知怎么被忽略了。链接变为 http://www.xxxxxx.com/index.php/categories/view/lang:chi 很明显,身份证号码不见了。链接应该是这样的 http://www.xxxxxx.com/index.php/categories/view/5/lang:chi 在视图文件中生成链接的代码如下 $t

我的视图包含一个用于更改页面语言的链接。索引、添加页面都很好。但是当涉及到“编辑”或“查看”页面时,如果在URL的末尾有一个ID号,那么这个数字在这个链接上不知怎么被忽略了。链接变为

http://www.xxxxxx.com/index.php/categories/view/lang:chi
很明显,身份证号码不见了。链接应该是这样的

http://www.xxxxxx.com/index.php/categories/view/5/lang:chi
在视图文件中生成链接的代码如下

$this->Html->link($language, array('lang' => $code));
我不知道为什么只有最后有ID号的URL才会出现这样的问题。我使用了烘焙,因此控制器视图操作如下所示:

    public function view($id = null) {
            $this->Category->id = $id;
            if (!$this->Category->exists()) {
                    throw new NotFoundException(__('Invalid category'));
            }
            $this->set('category', $this->Category->read(null, $id));
    }

有人知道发生了什么吗?

如果不在链接数组中指定id,它将不会被使用。如果省略它们,则只添加了控制器和动作

创建链接时,您需要传递id:

$this->Html->link($language, array('lang' => $code, $id));

非常感谢。这很有效。虽然我必须检查使用$this->request pass[0]的ID是否存在,如果存在,则将其用作$ID。还有其他更简单的方法吗?你可以在控制器中设置它,因为它已经被传递了,比如
$this->set('id',$id)