CodeIgniter+Ion Auth自定义页面模板错误


CodeIgniter + Ion Auth Custom Page Template Error

我想使用一个模板来加载我的页眉、主要内容和页脚。这似乎是最佳实践,而不是必须在每个单独的视图上加载页眉和页脚。

Auth.php控制器:

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);
} 

如果我注释掉_render_page行并将其替换为其他两行,我会收到未定义的变量错误,这是完全合理的。如何使用我的设置传递$message、$identity和$password变量?仅供参考,我的模板如下:

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

我应该改为编辑_render_page函数吗?感谢您提供的任何帮助。

您需要传递$this->数据,而不是$data