0

配列クラスを追加すると、ビューが複数のサブフォルダーに読み込まれません。カスタムコントローラークラスを作成して、コントローラーをコードイグナイターのコントローラーにロードできるようにしようとしています。

配列/変数をロードすると、ビューは最初のレベルでのみ機能します。2 つ以上のサブフォルダーを広告する場合、ピックアップしません。コントローラーを配列として追加するときに、複数のフォルダーを取得できるようにする必要があります。

MY_Loader.php

  public function controller($uri, $params = array(), $return = FALSE) {
   // No valid module detected, add current module to uri
      list($module) = $this->detect_module($uri);
      if (!isset($module)) {
            $router = & $this->_ci_get_component('router');
      if ($router->module) {
         $module = $router->module;
         $uri = $module . '/' . $uri;
      }
   }

   // Add module
   $this->add_module($module);

   // Execute the controller method and capture output
   $void = $this->_load_controller($uri, $params, $return);

   // Remove module
   $this->remove_module();

   return $void;
}

public function view($view, $vars = array(), $return = FALSE) {
        // Detect module
        if (list($module, $class) = $this->detect_module($view)) {
            // Module already loaded
            if (in_array($module, $this->_ci_modules)) {
                return parent::view($class, $vars, $return);
            }

            // Add module
            $this->add_module($module);

            // Let parent do the heavy work
            $void = parent::view($class, $vars, $return);

            // Remove module
            $this->remove_module();

            return $void;
        } else {
            return parent::view($view, $vars, $return);
        }
    }

コントローラ HMVC。

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Home extends CI_Controller {
    public function __construct(){
    parent::__construct();     
}

public function index() {
    $data['header'] = $this->load->controller('admin/common/header');
    $this->load->view('welcome_message', $data); Work
    $this->load->view('templates/welcome_message', $data); Not Work
    $this->load->view('templates/common/welcome_message', $data)//Not Work   
}
4

0 に答える 0