PHP kohana框架模板渲染问题-空白页面
我创建了一个函数来获取用户收件箱消息并使用“用户配置文件消息”模板显示它。 此外,如果用户单击“删除全部”按钮,我还添加了删除批量收件箱消息的功能(在同一功能中)。 但是删除所有消息后,页面/模板不会重新渲染。请让我知道可能是什么原因。
我正在使用以下方法渲染页面。
$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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先,如果您不扩展模板控制器,那么您的代码应该是:
Output is set by
$this->response->body($view).不需要调用 render,因为它有一个 __toString 方法。
如果您正在扩展模板控制器,看起来就是这样。它会自动渲染输出,除非您明确告诉它不要这样做:
默认情况下,它将使用包含您的视图的变量 body 渲染模板 template。
First of all, if you're not extending the template controller, then your code should be:
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:
By default, it's going to render the template template with a variable body which will contain your view.