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

  • Home
  • SEARCH
  • 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 3390842
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T03:44:17+00:00 2026-05-18T03:44:17+00:00

Attempting to learn CI and going through the docs to get a better understanding.

  • 0

Attempting to learn CI and going through the docs to get a better understanding. Without getting a separate library, I could make a template by including a list of views like so:

$this->load->view('header');
$this->load->view('navigation');
$this->load->view('sidenav_open');
$this->load->view('blocks/userinfo');
$this->load->view('blocks/stats');
$this->load->view('sidenav_close');
$this->load->view('content',$data);
$this->load->view('footer');

This makes sense but would I actually have that on each of my controllers (pages)? Not sure if there is a way to include this in the initial controller (welcome) and then in the others somehow reference it? Or perhaps there is something I am missing completely

  • 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-05-18T03:44:18+00:00Added an answer on May 18, 2026 at 3:44 am

    You can load views from within a view file. for example, consider a generic page template called page_template.php:

    <html>
    <body>
      <div id = "header">
          <?php $this->load->view('header');?>
          <?php $this->load->veiw('navigation');?>
      </div>
      <div id = "sidenav">
         <?php $this->load->view('sidenav');?>
      </div>
      <div id = "content">
         <?php echo $content;?>
       </div>
    
      <div id = "footer">
          <?php $this->load->view('footer');?>
     </body>
     </html>
    

    Load your more dynamic areas by making use of codeigniter’s abiltiy to return a view as a variable in your controller:

    $template['content'] = $this->load->view('content',$data,TRUE);
    $this->load->view('page_template',$template);
    

    By passing TRUE to the load function, CI will return the data from the view rather than output to the screen.

    Your sidenav section could be it’s own view file, sidenav.php, where you have your ‘blocks’ hard-coded or loaded similar to the above example.

    I’ve done it both ways, including every stinking bit of views in each controller method, and by using a page template that loads sub-views and dynamic areas, and by far, the second method makes me happier.

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

Sidebar

Related Questions

I'm attempting to learn VBA by reading through someone's code and understanding what happens
I am attempting to learn the PyMT library and am trying to implement a
I'm attempting to learn myself up on F#, and I fear I'm not understanding
I am attempting to learn Java Programming on my own (without classes/teachers/tutors/etc.) so this
To better myself I am attempting to make my dll's COM compliant, I thought
I have been attempting to learn Grails, however I am running into the following
I'm attempting to learn how to use Cucumber and creating steps using the following
I am attempting to learn J and the book I am using says this
I'm attempting to learn IronPython, to broaden my .NET horizons. I want to be
I've been attempting to learn programming (in C#) for a few years now. The

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.