viewcodeigniter-hmvc

view to view in HMVC Code Igniter


i have some problem with hmvc in codeigniter because im newbie with hmvc.

i have a template bootstrap with ci , so the problem like i not able to show my view

my view name index.php in directory "theme" :

<!DOCTYPE html>
<html lang="en">
<head>
    <?php echo $this->load->view('theme/header') ?>
</head>
<body>
<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
    <?php echo $this->load->view('theme/navbar') ?>
</nav>
<div id="wrapper">


    <div id="page-wrapper">
        <?php $this->load->view($content) ?>
    </div>

</div>
<?php echo $this->load->view('theme/footer') ?>
</body>

My Controller name dashboard in directory "theme" :

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Dashboard extends CI_Controller{

    function __construct()
    {
        parent::__construct();

    }
    function index()
    {
            $data['content'] = 'dashboard';
            return $this->load->view('theme/index', $data);
    }
}

i the error is in :

<?php echo $this->load->view('theme/navbar') ?>

and

<?php echo $this->load->view('theme/footer') ?>

the error Says :

"A PHP Error was encountered"

"Severity: 4096"

"Message: Object of class MY_Loader could not be converted to string"

"Filename: theme/index.php"

"Line Number : 8"

Please help


Solution

  • dont use echo
    just $this->load->view('viewfile')
    example if your view file is on application/view/theme/footer then it is

    $this->load->view('theme/footer')
    

    if you want to convert it to string you can pass a boolean true in Third parameter
    $this->load->view('theme/footer',array(),true)

    Please refer to this codeigniter's view's documentation