【问题标题】:CodeIgniter + Ion Auth Custom Page Template ErrorCodeIgniter + Ion Auth 自定义页面模板错误
【发布时间】: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


    【解决方案1】:

    你需要传递 $this->data,而不是 $data

    【讨论】:

    • 感谢您的快速回复。做到了!
    猜你喜欢
    • 2014-01-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-02-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多