是否可以在cakephp中的视图中显示子文件夹下的页面? 这是我的文件夹结构:
<pre>
-Views
|-Elements
|-Emails
|-Errors
|-Helpers
|-Homes
|-Layouts
|-Messages
|-Pages
|-Resources
|-Scaffolds
|-Tutors
|-ManageStudents
|-addlectures.ctp
|-editlecture.ctp
|-deletelecture.ctp
|-managestudents.ctp
|-index.ctp
|-profile.ctp
|-Webroots
</pre>
现在如何在tutors / managestudents下显示ctp文件? 我尝试在浏览器中输入localhost / school / tutors / managestudents / addlectures,但这并不起作用。
我也尝试过使用html帮助链接,但仍然没有运气
$this -> html -> link ('Add lectures, array('controller' => 'tutors, 'action' => 'ManageStudents/addlectures');
从我观察到的蛋糕只显示视图下的文件,但它无法访问子文件夹中的文件。
答案 0 :(得分:1)
首先在TutorsController.php
中,你必须像ff:
...
public function addlectures() {
...
$this->render('ManageStudents/addlectures');
}
....
然后,你必须在app / Config中配置routes.php
,如下所示:
...
Router::connect('/Tutors/ManageStudents/addlectures', array('controller' => 'tutors, 'action'=> 'addlectures'));
..
这样你可以添加如下链接:
$this->Html->link ('Add lectures, array('controller'=>'tutors, 'action' =>'addlectures');
,浏览器会输出..../Tutors/ManageStudents/addlectures
注意:整个Tutors文件夹应位于app / Views文件夹
中
希望它有帮助!