在CodeIgniter 3 HMVC中创建子文件夹的问题

时间:2018-04-16 10:54:54

标签: php codeigniter codeigniter-3 hmvc

我有一个包含多个子文件夹的项目,例如:

  1. client / auth / login = model / view / controller
  2. client / auth / signup = model / view / controller
  3. admin / signin = model / view / controller
  4. 我设置了这样的路线:

    $route['default_controller'] = "admin/signin/signin";
    $route['admin/sigin'] = "admin/sigin/signin/index";
    $route['admin/(:any)'] = "admin/sigin/signin/";
    $route['client/auth'] = "auth/login/login";
    

    这些路线无效,显示CodeIgniter 404错误页。

2 个答案:

答案 0 :(得分:0)

$route['default_controller'] = "admin/signin/signin";
$route['admin/signin'] = "admin/signin/signin/index";
$route['admin/(:any)'] = "admin/signin/signin/$1";
$route['client/auth'] = "auth/login/login";

修正了上面的拼写错误。 我认为你的文件结构不正确。我使用CI2,不知道模块如何在CI3中工作。但模块'forgot_password'和'signin'会使用相同的模型吗?为什么将它们放在单独的文件夹/模块中这样,当您对用户模型进行更改时,您将不得不在所有模块中的每个用户模型中进行更改(除非在这种情况下您不需要它,但我仍然不会冒险构建我的应用程序那)

- modules
    - Admin
        - controllers
            - user.php // Will have methods like signin(), add(), view(),...
    - Client
        - controllers
            - auth.php // Will have methods like signin(), signout(), ...
        - models // This will hold models you don't need in Admin module
                 // other models should be in the default models folder, so each module will be able to access them.

路线如下:

$route['default_controller'] = "admin/user/signin"; // admin module, user controller, signin method
$route['admin/signin'] = "admin/user/signin";
$route['admin/(:any)'] = "admin/content/$1"; // admin module, content controller, (:any) method (content being an example, I have it in my CMS project)
$route['client/auth'] = "client/auth/login"; // client module, auth controller, login method

答案 1 :(得分:0)

我解决了..在配置文件中,我添加了以下代码行;

$(document).ready(function() {      
    SearchColumn();
    document.onkeydown = function (e) {
        if (e.keyCode === 13) {
            document.getElementById('searching').click(); return false;
        }
    }
    var prm = Sys.WebForms.PageRequestManager.getInstance();    
    //prm.add_initializeRequest(InitializeRequest);
    prm.add_endRequest(EndRequest);     
});

function EndRequest(sender, args) {
   // after update occur on UpdatePanel re-init the Autocomplete
   SearchColumn();
}

它就像一种魅力..:)