Templates Kohana模板$content变量不显示任何内容
我有一个扩展Kohana模板类的Kohana控制器。Kohana模板类具有Templates Kohana模板$content变量不显示任何内容,templates,kohana,Templates,Kohana,我有一个扩展Kohana模板类的Kohana控制器。Kohana模板类具有 const CONTENT_KEY = 'content'; 在此控制器中,我已声明要使用的模板视图: public $template = 'homepage_template'; 在这个控制器中,我还有一些方法和一些相关的视图 有了所有这些,当我在主页_模板视图中echo$content时,没有显示任何内容(视图中没有属于此控制器操作的内容)。(我在动作中自动渲染为true)。原因是什么?我就是这样使用Templ
const CONTENT_KEY = 'content';
在此控制器中,我已声明要使用的模板视图:
public $template = 'homepage_template';
在这个控制器中,我还有一些方法和一些相关的视图
有了所有这些,当我在主页_模板视图中
echo$content
时,没有显示任何内容(视图中没有属于此控制器操作的内容)。(我在动作中自动渲染为true)。原因是什么?我就是这样使用Template Controller的,希望它能帮助:
<?php defined('SYSPATH') or die('No direct script access.');
class Controller_Template_Default extends Controller_Template
{
public $template = 'templates/default';
protected $auth;
protected $user;
public function before()
{
parent::before();
Session::instance();
$this->auth = Auth::instance();
if (($this->user = $this->auth->get_user()) === FALSE)
{
$this->user = ORM::factory('user');
}
if($this->auto_render)
{
$this->template->title = '';
$this->template->meta_keywords = '';
$this->template->meta_description = '';
$this->template->meta_copywrite = '';
$this->template->header = '';
$this->template->content = '';
$this->template->footer = '';
$this->template->styles = array();
$this->template->scripts = array();
$this->template->bind_global('user', $this->user);
}
}
public function after()
{
if($this->auto_render)
{
$styles = array('css/default.css' => 'screen', 'css/reset.css' => 'screen');
$scripts = array('js/infieldlabel.js', 'js/menu.js', 'js/jquery.js');
$this->template->styles = array_reverse(array_merge($this->template->styles, $styles));
$this->template->scripts = array_reverse(array_merge($this->template->scripts, $scripts));
}
parent::after();
}
} // End Controller_Template_Default
这是什么版本的Kohana?能否在应用程序中提供更具体的文件路径?您是否已检查Web服务器错误日志中是否存在任何无提示错误?能否更具体地说明您正在使用的“Kohana template”类?你是说Kohana模板控制器吗?如果是这样,您是否在操作中实际设置了内容视图变量?例如:$this->template->content=View::factory('whatever')。此外,正如Lathargy所提到的,了解您正在使用的Kohana版本将非常有用。