【发布时间】:2012-06-14 14:47:56
【问题描述】:
我的视图包含一个用于更改页面语言的链接。索引,添加页面都很好。但是,当涉及到 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 有这样的问题。我使用了 bake 所以控制器视图操作是这样的:
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));
}
有人知道怎么回事吗?
【问题讨论】:
标签: cakephp html-helper