Welcome Guest, Not a member yet? Register   Sign In
View Loaded Twice
#1

[eluser]domoench[/eluser]
Hi All,

I recently noticed my backend controller is loading its default view twice and I can't spot why. My code is as follows:

The Controller: backend.php
Code:
class Backend extends CI_Controller {
    
    public function __construct() {
        parent::__construct();
        $this->is_logged_in();
    }    
    
    function is_logged_in() {
        $is_logged_in = $this->session->userdata('is_logged_in');
        
        if(!isset($is_logged_in) || $is_logged_in != true) {
            redirect('login/index');
            die();
        }
        else $this->index();
    }

    public function index() {
        $this->load->model('blog_model');
        
        // Pagination
        $this->load->library('pagination');
        $config['base_url'] = base_url() . 'index.php?/backend/index/';
        $config['total_rows'] = $this->blog_model->getNumRows();
        $config['per_page'] = 10;
        $config['full_tag_open'] = '<div id="pagination">';
        $config['full_tag_close'] = '</div>';
        $this->pagination->initialize($config);
        
        $data['rows'] = $this->blog_model->getposts($config);
        
        $data['main_content'] = "backend_blog_view";
        $this->load->view('includes/backend_template', $data);
    }
        
    // Other functions
}

The View: backend_template.php

Code:
&lt;?php $this->load->view('includes/backend_header'); ?&gt;
&lt;?php $this->load->view($main_content); ?&gt; //backend_blog_view in this case
&lt;?php $this->load->view('includes/backend_footer'); ?&gt;
For simplicity I have not included the code for the header, content, and footer view that the call to load backend_template.php actually entails - but I have checked through to be sure my doubling problem is not in backend_template.php or its component views.

I suspect the problem lies in the above controller - could anyone give me a hint? If the above code is not sufficient to see the problem please let me know what other code would be useful to look through.

Thanks!
-David




Theme © iAndrew 2016 - Forum software by © MyBB