Kohana 3.3请求和回复

时间:2015-02-22 19:31:09

标签: request response kohana

一个教程认为我可以通过以下方式填充我的模板内容:

$this->template->body = $this->response->body();

但是,我无法看到响应的填充位置。即使转储请求和响应,它也只是空的。

其次,我如何利用已经内置的Request类来从函数中获取一些输出,而不实际重定向到该方法?让我们说:

$content = Request::factory('news/latest')->execute();
亲切的问候。

1 个答案:

答案 0 :(得分:0)

使用$this->template->body假设您使用的是Controller_Template控制器。 $this->templateController_Template中的变量,表示查看文件application/views/template.php

将某些内容设置为$this->template->body会将$body变量传递给模板视图文件。您可以在模板视图中使用它(如echo $body;)。

要从$content = Request::factory('news/latest')->execute();获取输出,你的控制器处理news/latest路由必须产生一些输出。 你可以得到这样的输出:

$response = Request::factory('news/latest')->execute();
$content = $response->body();
相关问题