Reputation: 718
Im using CI-HMVC stock. Id like to have a module structure like this:
application modules userabc moduleA controllers models views moduleB ... userDEF moduleC ...
Is this an incorrect way of module organization? Is there another common way of doing something like this?
Im wanting to seperate the users module folders and use them in a URL like this:
userABC.domain.com/module/controller/method
userBCD.domain.com/module/controller/method
Upvotes: 0
Views: 2809
Reputation: 58
Adding submodules in codeigniter you need to defile moudules direcotry in config file like this.
$config['modules_locations'] = array(
APPPATH.'modules/' => '../modules/backend/',
APPPATH.'modules/frontend/' => '../modules/frontend/',
);
Upvotes: 1
Reputation: 102745
You can use that structure if you want, but keep in mind the following:
You must define each user's directory as a module location:
// application/config/config.php
$config['modules_locations'] = array(
// Absolute path // Relative from default application dir
APPPATH.'modules/userABC/' => '../modules/userABC/',
APPPATH.'modules/userDEF/' => '../modules/userDEF/',
APPPATH.'modules/userGHI/' => '../modules/userGHI/',
// etc.
);
You might be able to do this dynamically, but remember that config.php
is loaded pretty early so you may need a pre_system
hook.
The other thing, which is important if you want all users' modules accessible regardless of which subdomain is active: Order matters!
If userA has a module called "blog" and so does userB, only userA's will ever get loaded (assuming you define userA's module path first). If you're certain no two modules will share the same name, this won't matter as much, but you may suffer a performance hit as the loader will go through the whole stack of module locations until it finds the requested one.
It sounds like you should define a single module_location
depending on what user's site is loaded (the subdomain). Something like:
// Get this value dynamically (not sure how you need to do it)
$current_user = 'userABC';
$config['modules_locations'] = array(
APPPATH.'modules/'.$current_user.'/' => '../modules/'.$current_user.'/'
);
Upvotes: 1