PHP kohana framework template rendering issue - blank page
Asked Answered
S

1

6

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.

Screed answered 30/5, 2011 at 5:46 Comment(3)
Are you echoing $body in your template view?Impending
No. I am using View::factory()->render() method to display the templates.Screed
render() just converts View object to a string. Alex means that you need to display $body var somewhere in your $this->template View.Deimos
D
2

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.

Dugan answered 30/5, 2011 at 13:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.