Welcome Guest, Not a member yet? Register   Sign In
Views Not Loading, But Echoing View Data Works
#1

[eluser]Unknown[/eluser]
I have a very large CI app that we’ve been developing for about 6 months. I love the simplicity and flexibility of CI and have had a lot of success. I wouldn’t call myself a CI expert, but I’m very familiar.

I’m refactoring some common controllers into a core controller to simplify my codebase. In doing so, I’ve come across a very strange problem.

The load view function will not work, but ONLY in this instance. The two calls I have below are in a core controller and are called from throughout the application - and they work 100% of the time, except in my new controller. They’re all being called via a parent::render function (since they’re all based on extended controllers).

In any case, if I run this line of code from my new controller, nothing happens:

Code:
$this->load->view("templates/header", $data);

But the bizarre thing to me is that if I run this instead, it works perfectly.

Code:
echo $this->load->view("templates/header", $data, TRUE);

It’s true that I could just change all my load view functions to echo the data from the view, but that seems sloppy and I’m sure someone else has had this bug, but I was not able to find a way to fix this in the forum.

It seems likely to me that this is a problem with my new controller code, but it seems really strange to me that it would work with one way (via echoing the view data) but not the other (just executing the view function) since they should be equivalent function calls…

Any ideas would be appreciated.
#2

[eluser]Unknown[/eluser]
I figured this out, but figured I'd post an update in case anyone else finds themselves having the same issue.

As usual, it was something really dumb. I had a fatal error in my PHP, but that part of the view was actually outputting to a hidden div, so I wasn't seeing the "Fatal Error" output. Once I unhid everything on the view, everything was fine.
#3

[eluser]boltsabre[/eluser]
Quote: I had a fatal error in my PHP, but that part of the view was actually outputting to a hidden div, so I wasn’t seeing the “Fatal Error” output.

Hahaha, classic!!! This is why I love web/app development, there is ALWAYS something that drives you nuts and keeps life interesting! Glad you found the answer!!!




Theme © iAndrew 2016 - Forum software by © MyBB