Manish Tiwari
Manish Tiwari

Reputation: 1866

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') ?>

Upvotes: 2

Views: 4322

Answers (2)

Ankush Srivastava
Ankush Srivastava

Reputation: 502

Folder structure

application/view/template
application/view/site

$this->load->view('template/header');
$this->load->view('site/dashboard');
$this->load->view('template/footer');

Upvotes: 1

Jaydeep Baldaniya
Jaydeep Baldaniya

Reputation: 123

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');
    }

Upvotes: 1

Related Questions