0

I am new to codeignitor as separating my website into three like header,body,footer I have create header and footer controller and view page.I am facing a problem how to include both the controller in body controller like include('.php') in php

1 Answer 1

1

The html for your pages should be in the views, not in the controllers.

Your choices are;

1) create a view for each section, then call them all from a controller

class Foo extends CI_Controller {
public function index() {
    $data = array(); // put data in here
    $this->load->view('header', $data);
    $this->load->view('main, $data);
    $this->load->view('footer', $data);
}

2) call others views from the main content view

// in view for html page
<?php $this->load->view('header'); ?>
<h1>My Page</h1>
<?php $this->load->view('footer'); ?>

3) or use a template library, like this one for example

If you really want to go down the controller inside controller routes, look at hmvc for codigniter

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.