【发布时间】:2015-07-21 00:24:06
【问题描述】:
到目前为止,一切都运行良好。我在页面上:http://framework.zend.com/manual/current/en/in-depth-guide/understanding-routing.html。
在这个页面上我必须修改 3 个文件:
-module.config.php
-detail.phtml
-ListController.php
我收到以下错误:
帖子详情
帖子标题
致命错误:在线调用 C:\Program Files\xampp\htdocs\path\to\zf2-tutorial\module\Blog\view\blog\list\detail.phtml 中的成员函数 getTitle() on null 6
我没有粘贴代码,因为它与链接中的相同。你们能帮我解决我的问题吗?
公共函数detailAction()
{
$id = $this->params()->fromRoute('id');
try {
$post = $this->postService->findPost($id);
} catch (\InvalidArgumentException $ex) {
return $this->redirect()->toRoute('blog');
}
return new ViewModel(array(
'post' => $post
));
}
【问题讨论】:
-
有点宽泛......如果你按照教程所说的去做,它应该可以工作。如果没有,也许你忘记了什么。您必须再次阅读并检查您是否按照所说的一切...
-
我检查了三次。我不认为是我的错误。恐怕教程有问题。
-
我们需要在DetailController的detailAction中看到你的代码。根据您在教程中所处的位置,您会得到不同的结果。在第一部分,我怀疑你在哪里,实际上你应该得到一个异常,唉。
-
我已经编辑了最初的帖子并添加了 detailAction。但正如我在最初的帖子中所说,它与他们网站上的相同。
标签: php zend-framework zend-framework2