Reputation: 159
I deployed an app and I've got a problem. This is my controller:
class Account extends CI_Controller {
function test() {
echo "hello";
$this->load->view('account/test');
echo "hello again";
}
The output shows hellohelloagain
.
The load->view()
method is not called. This happens in all controllers.
The problem doesn't exist in development environment.
I have already:
There are no warnings or errors in my Apache logs.
UPDATE
I just discovered something weird:
function index() {
$this->load->view('welcome/index'); // NOTHING
$output = $this->load->view('welcome/index', array(), true);
echo $output; // WORKS FINE
}
Upvotes: 2
Views: 910
Reputation: 159
Resolved:
I commited a mistake in my hook configuration:
$hook['display_override'][] = array('class' => 'layout', 'function' => 'show_layout', 'filename' => 'layout.php', 'filepath' => 'hooks');
Actually, the real name is Layout.php, while the configuration required layout.php.
Thanks everybody
Upvotes: 0
Reputation: 31
have you try to create separate view for each echo like this?
class Account extends CI_Controller {
function test() {
$this->load->view('account/hello');
$this->load->view('account/test');
$this->load->view('account/hello-again');
}
}
Upvotes: 1
Reputation: 38584
class Account extends CI_Controller
{
function test() {
echo "hello";// No 01
$this->load->view('account/test'); //No 02
echo "hello again"; //No 03
}
in No 01 it will show hello
word as you mentioned. And again you loading a view in No 02(this view is blank page, other wise you get error page not found).
Error is :
An Error Was Encountered
Unable to load the requested file: account/test.php
So your test view is empty page. then in No 03 your are passing hello again
. so this will also appear in your view.
so your final output come as hellohello again
.
So Finely it means your code is working perfectly and well.
To test your view whether working or not
In your view(test.php) write this line and see the output
<h1>Hi, I'm here</h1>
read this for further Knowledge
Upvotes: 1