模板库不适用于HMVC Codeigniter

时间:2018-11-27 18:24:09

标签: php codeigniter hmvc-codeigniter

我正在使用此库代码在HMVC codeigniter中功能性地使用模板,但其显示“无法加载请求的文件:/。php”

class Template
{
    var $ci;

    function __construct() 
    {
        $this->ci =& get_instance();
    }

    function load($tpl_view, $body_view = null, $data = null) 
    {
        if ( ! is_null( $body_view ) ) 
        {
            if ( file_exists( APPPATH.'views/'.$tpl_view.'/'.$body_view ) ) 
            {
                $body_view_path = $tpl_view.'/'.$body_view;
            }
            else if ( file_exists( APPPATH.'views/'.$tpl_view.'/'.$body_view.'.php' ) ) 
            {
                $body_view_path = $tpl_view.'/'.$body_view.'.php';
            }
            else if ( file_exists( APPPATH.'views/'.$body_view ) ) 
            {
                $body_view_path = $body_view;
            }
            else if ( file_exists( APPPATH.'views/'.$body_view.'.php' ) ) 
            {
                $body_view_path = $body_view.'.php';
            }
            else
            {
                show_error('Unable to load the requested file: ' . $tpl_name.'/'.$view_name.'.php');
            }

            $body = $this->ci->load->view($body_view_path, $data, TRUE);

            if ( is_null($data) ) 
            {
                $data = array('body' => $body);
            }
            else if ( is_array($data) )
            {
                $data['body'] = $body;
            }
            else if ( is_object($data) )
            {
                $data->body = $body;
            }
        }

        $this->ci->load->view('template/'.$tpl_view, $data);
    }
}

我正在使用:

$this->template->load('main','dashboard/dashboard');

这是我的文件夹结构:

here is my folder structure

0 个答案:

没有答案
相关问题