PHP kohana框架模板渲染问题-空白页面

发布于 2024-11-10 13:21:30 字数 374 浏览 1 评论 0原文

我创建了一个函数来获取用户收件箱消息并使用“用户配置文件消息”模板显示它。 此外,如果用户单击“删除全部”按钮,我还添加了删除批量收件箱消息的功能(在同一功能中)。 但是删除所有消息后,页面/模板不会重新渲染。请让我知道可能是什么原因。

我正在使用以下方法渲染页面。

 $this->template->body = View::factory("user-profile-messages", array(
            "msg" => $msg,
            "messages" => $messages,
        ))->render();

我正在使用 Kohana 最新版本。

I have created one function to fetch the user inbox message and display it using "user-profile-messages" templates.
Also I have added functionality (in the same function) to deleting bulk inbox message if user clicked on delete all button.
But after deleting all messages, page/template is not redering. Please let me know what could be the reason.

I am rendering page using below method.

 $this->template->body = View::factory("user-profile-messages", array(
            "msg" => $msg,
            "messages" => $messages,
        ))->render();

I am using Kohana latest version.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

绾颜 2024-11-17 13:21:30

首先,如果您不扩展模板控制器,那么您的代码应该是:

$view = View::factory("user-profile-messages", array(
    "msg" => $msg,
    "messages" => $messages,
));

$this->response->body($view)

Output is set by $this->response->body($view).不需要调用 render,因为它有一个 __toString 方法。


如果您正在扩展模板控制器,看起来就是这样。它会自动渲染输出,除非您明确告诉它不要这样做:

$this->auto_render = FALSE;

默认情况下,它将使用包含您的视图的变量 body 渲染模板 template

First of all, if you're not extending the template controller, then your code should be:

$view = View::factory("user-profile-messages", array(
    "msg" => $msg,
    "messages" => $messages,
));

$this->response->body($view)

Output is set by $this->response->body($view). Calling render isn't needed as it has a __toString method.


If you're extending the template controller, which it looks like you are. It renders output automatically unless you explicity tell it not to:

$this->auto_render = FALSE;

By default, it's going to render the template template with a variable body which will contain your view.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文