【发布时间】:2013-08-31 20:50:12
【问题描述】:
我想使用模板来加载我的页眉、主要内容和页脚。这似乎是最佳实践,而不是必须在每个单独的视图上加载页眉和页脚。
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 函数吗?感谢您提供的任何帮助。
【问题讨论】:
标签: php codeigniter authentication ion-auth