Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9117855
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T04:59:44+00:00 2026-06-17T04:59:44+00:00

I have this code, and when I call the function with mydomain/index.php/blog everything works,

  • 0

I have this code, and when I call the function with mydomain/index.php/blog everything works, but the content i.e “index” in this case is being displayed in the top of the page.
I want it to be displayed in the content area, that i have defined in my css. Whats the problem?

<?php
    class Blog extends CI_Controller{

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

        public function index(){

            $this->load->view('template/header');
            echo "index";
            $this->load->view('template/footer');
        }

    }
    ?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T04:59:46+00:00Added an answer on June 17, 2026 at 4:59 am

    There are two ways to display output to the browser in CodeIgniter. Using the CI views and just echoing out the data. The echo command executes immediately, so that’s why it is at the top of the page. The load->view method is executed within CI in the output library – so it’s not executed exactly in order of your echo statement.

    I would say to create another view for your content, then call all views like this:

    $data = array('content_html' => 'index');
    $this->load->view('template/header');
    $this->load->view('template/content', $data);
    $this->load->view('template/footer');
    

    Your content view could just echo out the content_html variable:

    // views/template/content.php
    echo $content_html;
    

    Alternatively, you can control the content in your controller (although, not the best of ideas):

    $header = $this->load->view('template/header', array(), TRUE);
    $footer = $this->load->view('template/footer', array(), TRUE);
    
    echo $header;
    echo "index";
    echo $footer;
    

    Passing TRUE as the third parameter to the load->view method returns the view as a string instead of outputting it to the browser – allowing you to control the output.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code : include(connect.php); // Call database function $p = 100; $sth
I have this follow code in my javascript. I call this function when the
I have this code where I need to call a function multiple times. $(window).resize(function()
I have this code. From main function i twice call sportPrisevinners function and if
I have this code that make an image animation, but I want to call
I have this code inside the success function of a jQuery ajax call success:
I have this code inside thread and when I call terminate it terminates fast
I have this code: http://pastebin.com/Sd9WKZFr When i call something like rate(60, -6000, 120000) it
On my main page I have this jquery code which does an ajax call
I have code that looks something like this in javascript: forloop { //async call,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.