Welcome Guest, Not a member yet? Register   Sign In
How to handle controller for every reload ?
#5

[eluser]SitesByJoe[/eluser]
Here's the bit you are missing - your view can call other views. I usually pass the content bits within each page as an array from the controller, sort of like this:

My Controller (snippet):

Code:
<?php
// I'm skipping the other controller code
$data['contents'] = array(
  'section_a',
  'section_b',
  'etc'
);
// load your main view from the controller and pass over your array
$this->load->view('my_view', $data);

My view:

Code:
<html>
  <body>
    <?php $this->load->view('header'); ?>
    // loop through your array and add your views
    <?php
    foreach($contents as $section)
    {
      $this->load->view($section);
    }
    ?>

    <?php $this->load->view('footer'); ?>
  </body>
</html>

This is a very simple example at least to get the idea across. I recall having trouble absorbing this when I first started with CI.


Messages In This Thread
How to handle controller for every reload ? - by El Forum - 09-30-2008, 03:22 AM
How to handle controller for every reload ? - by El Forum - 09-30-2008, 04:14 AM
How to handle controller for every reload ? - by El Forum - 09-30-2008, 04:29 AM
How to handle controller for every reload ? - by El Forum - 09-30-2008, 05:18 AM
How to handle controller for every reload ? - by El Forum - 09-30-2008, 07:18 AM
How to handle controller for every reload ? - by El Forum - 09-30-2008, 09:02 AM



Theme © iAndrew 2016 - Forum software by © MyBB