phpcodeigniterauthenticationion-auth

CodeIgniter + Ion Auth Custom Page Template Error


I want to use a template to load my header, main content and footer. This seems like best practice as opposed to having to load the header and footer on each individual view.

Auth.php controller:

else
{
//the user is not logging in so display the login page
//set the flash data error message if there is one
$this->data['message'] = (validation_errors()) ? validation_errors() : $this->session->flashdata('message');

$this->data['identity'] = array('name' => 'identity',
 'id' => 'identity',
 'type' => 'text',
 'value' => $this->form_validation->set_value('identity'),
);
$this->data['password'] = array('name' => 'password',
 'id' => 'password',
 'type' => 'password',
);

//$this->_render_page('auth/login', $this->data);

$data['main_content'] = './auth/login';
$this->load->view('./includes/template', $data);
} 

If I comment out the _render_page line and replace it with the other two lines I receive undefined variable errors, which makes perfect sense. How would I be able to pass the $message, $identity and $password variables using my setup? FYI, my template looks like this:

<?php $this->load->view('includes/header'); ?>
<?php $this->load->view($main_content); ?>
<?php $this->load->view('includes/footer'); ?>

Should I be editing the _render_page function instead? Thanks for any help you can provide.


Solution

  • you need to pass $this->data, not $data