Welcome Guest, Not a member yet? Register   Sign In
Where do you put header.php and footer.php?
#6

[eluser]jshultz[/eluser]
Here's more from my site controller:
Code:
function index()
    {

          $data['user_id']    = $this->tank_auth->get_user_id();
          $data['username']    = $this->tank_auth->get_username();
          $data['page_title'] = 'OSM Projects';
          $data['page'] = 'welcome'; // pass the actual view to use as a parameter
          $this->load->view('container',$data);

    }

    function about()
    {
          $data['user_id']    = $this->tank_auth->get_user_id();
          $data['username']    = $this->tank_auth->get_username();
          $data['page_title'] = 'OSM Projects';
          $data['page'] = 'about'; // pass the actual view to use as a parameter
          $this->load->view('container',$data);
        
    }

function project_list()
    {
          if (!$this->tank_auth->is_logged_in()) {
            redirect('/auth/login/');
          } else {
            $this->load->model('Project_model');
            /*$data['query'] = $this->Project_model->getAll();*/
            $data['query'] = $this->Project_model->getByUserId();
            $data['user_id']    = $this->tank_auth->get_user_id();
            $data['username']    = $this->tank_auth->get_username();
            $data['page_title'] = 'OSM Projects';
            $data['page'] = 'project-list-view'; // pass the actual view to use as a parameter
            $this->load->view('container',$data);
        
        }

    }


$data[] is an array. i'm assigning the value 'about' or 'project-list-view' or 'welcome' to the key 'page' in the $data array.

when the container loads it now begins loading the the various values from the $data array. Now, in regards to the question why $page has a $ in front of it in the container view and it doesn't in the site controller? I'm not sure. I just know it needs to be done or it breaks. Hopefully, somebody reading this can weight in on that.

Here's my educated guess:

$data[] is an array and as such you have to have the $ at the beginning in the site controller however $data['page'] doesn't require it because in this context it's page is a key in the array. However, in the view $page is a variable (albeit a part of the $data array) and you have to write it as $page in the view in order to have it render correctly.

Thank you for asking the question, though. Like I said earlier, I'm learning, too, and this makes me think more about what I'm doing and helps me to learn as well.


Messages In This Thread
Where do you put header.php and footer.php? - by El Forum - 08-06-2009, 01:55 PM
Where do you put header.php and footer.php? - by El Forum - 08-06-2009, 02:14 PM
Where do you put header.php and footer.php? - by El Forum - 08-06-2009, 03:20 PM
Where do you put header.php and footer.php? - by El Forum - 08-06-2009, 05:23 PM
Where do you put header.php and footer.php? - by El Forum - 08-07-2009, 10:19 AM
Where do you put header.php and footer.php? - by El Forum - 08-07-2009, 10:34 AM
Where do you put header.php and footer.php? - by El Forum - 08-07-2009, 11:47 AM
Where do you put header.php and footer.php? - by El Forum - 08-07-2009, 02:11 PM
Where do you put header.php and footer.php? - by El Forum - 08-07-2009, 02:36 PM
Where do you put header.php and footer.php? - by El Forum - 08-08-2009, 08:58 AM
Where do you put header.php and footer.php? - by El Forum - 08-09-2009, 09:58 AM
Where do you put header.php and footer.php? - by El Forum - 08-09-2009, 10:09 AM
Where do you put header.php and footer.php? - by El Forum - 08-09-2009, 12:07 PM
Where do you put header.php and footer.php? - by El Forum - 08-09-2009, 12:15 PM
Where do you put header.php and footer.php? - by El Forum - 09-24-2009, 08:47 PM
Where do you put header.php and footer.php? - by El Forum - 09-25-2009, 03:56 AM
Where do you put header.php and footer.php? - by El Forum - 09-25-2009, 06:21 AM
Where do you put header.php and footer.php? - by El Forum - 09-25-2009, 03:36 PM
Where do you put header.php and footer.php? - by El Forum - 09-26-2009, 02:21 PM
Where do you put header.php and footer.php? - by El Forum - 09-28-2009, 02:24 AM



Theme © iAndrew 2016 - Forum software by © MyBB