CodeIgniter模块文件夹结构和进入资产文件

时间:2017-04-27 13:06:06

标签: php codeigniter module codeigniter-hmvc

我的网站上有很多模块(CI 2.2.1),我想创建一个新功能的更大部分。这就是为什么我决定将新创建的模块分开并将它们放入模块文件夹中的一个文件夹,名为new_modules。我能够设置一切正常工作,我的模块几乎正确启动。唯一的问题是访问这种文件夹结构中的资产文件。示例结构:

--application/
----modules/
------module_1/
--------assets/
----------img/
------------file_1.jpg /* this file I can access by: base_url().'module_1/assets/img/file_1.jpg' */
--------controllers/
----------module_1.php
------new_modules/ /* folder where I want to hold several new modules */
--------new_module_2/
----------assets/
------------img/
--------------file_2.jpg /* I cannot access to this file */
----------controllers/
------------new_module_2.php /* but this module runs correctly, only without imgs, js and css :( */

在我的配置文件中,我添加了新路径并开始工作:

$config['modules_locations'] = array(
    APPPATH.'modules/' => '../modules/',
    APPPATH.'modules/new_modules/' => '../modules/new_modules/'
);

我可以通过浏览器访问普通模块中的文件:

base_url().'module_1/assets/img/file_1.jpg'

但是当我尝试访问new_module文件夹中的某些内容时,我得到404.我正在尝试:

base_url().'new_module_2/assets/img/file_2.jpg'

还有:

base_url().'new_modules/new_module_2/assets/img/file_2.jpg'

是否有需要编辑的配置?或者是否无法将多个模块嵌套在模块目录中的一个文件夹中?

0 个答案:

没有答案