Manish Tiwari Manish Tiwari - 4 years ago 182
PHP Question

How to include header file in main file in the View Folder using php Codeigniter?

I have two folder in View Folder


  1. Layout Folder :- in this folder I have create two files header.php and footer.php

  2. Agent Folder :- In this folder iIhave Main file dashboard.php.



I want to include header and footer file from layout folder to Dashboard.php.

I am using this code:

<?php include('../layout/header.php') ?>

Answer Source

Try this:

$this->load->view('layout/header');
$this->load->view('layout/footer');

In controller function just load using this code:

public function index()
    {
            $this->load->view('layout/header');
            $this->load->view('agent/dashboard');
            $this->load->view('layout/footer');
    }
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download