I am making a simple application and I am familiar with CodeIgniter 1.7.3, which I didn’t have any problems putting sub folders into the application/views folder.
My problem is specifically when I try and load the view, I get the standard CI error message of An Error Was Encountered Unable to load the requested file: usercontentpages/testview.php
However if I move the view file out of the sub folder and place it in the application/views folder the load view command works fine?
I can’t find any documentation in the user guide on why this is so?
Here is my Controller:
<?php
class Pages extends CI_Controller
{
//Controller Constructor
public function __construct()
{
parent::__construct();
}
//Home Page (Default)
public function index()
{
//Loading a Partial View
$mContent = $this->load->view('home', '', TRUE); //this works
//$mContent = $this->load->view('subfolder/home', '', TRUE); //this doesn't work
$data = array(
'mainContent' => $mContent,
);
//Passing the partial view to the master page
$this->load->view('usermasterpage', $data);
}
}
?>
Here is my Master Page:
<?php
//Doctype
echo doctype('html');
?>
<html>
<head>
<meta charset="utf-8">
</head>
<body onload="OnLoad()">
<div id="wrap">
<!-- Main Content Div -->
<div id="mainContent">
<?php
/* Every page will have a main content area */
if(isset($mainContent))
{
echo $mainContent;
}
?>
</div>
</div>
</body>
And Finally here is the page snippet I’m trying to load:
<p>Hi there</p>
CodeIgniter will successfully use nested views: I use nested views all the time and I know others who do as well, and it works out of the box. Show some code so we can see what you’re doing wrong.