【发布时间】:2016-07-13 22:46:43
【问题描述】:
总的来说,我对 FuelPHP 和 PHP / 框架非常陌生,并且设法完成了所有设置和一些控制器的运行等。但是我不确定如何将我设置的变量传递给 template.php 文件。
app/views/template.php
有问题的部分:
<body class="<?php echo $bodyClass; ?>">
app/classes/controller/dashboard.php
class Controller_Dashboard extends Controller_Template
{
/**
* The basic welcome message
*
* @access public
* @return Response
*/
public function action_index()
{
return Response::forge(View::forge('dashboard/index'));
}
/**
* The 404 action for the application.
*
* @access public
* @return Response
*/
public function action_404()
{
return Response::forge(Presenter::forge('dashboard/404'), 404);
}
}
app/classes/view/dashboard/index.php
class View_Dashboard_Index extends ViewModel
{
/**
* Prepare the view data, keeping this in here helps clean up
* the controller.
*
* @return void
*/
public function view()
{
$this->template = $this->request()->param('bodyClass', '');
}
}
我确定我弄错了,很明显我是因为它不工作,我明白了:
Fuel\Core\PhpErrorException [ Notice ]:
Undefined variable: bodyClass
C:/Websites/Annilla/Clients/Four04 Packaging/DEV/NEW/BUILD/backend/app/views/template.php @ line 24
有什么想法吗?
另外一件事,是否可以在菜单、页眉、页脚等中添加部分内容?
【问题讨论】: