This can be useful to prevent accessing some modules by URL.
This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.
The active forums are here.
March 03, 2008 6:10pm
Subscribe [48]#616 / Aug 13, 2008 11:00am
This can be useful to prevent accessing some modules by URL.
#617 / Aug 13, 2008 1:38pm
This can be useful to prevent accessing some modules by URL.
I’m thinking the same thing.
#618 / Aug 13, 2008 3:22pm
but you can do that by putting an underscore in front of the controller method… OR you could extend that convention to apply to module directory names: instead of “blocks” you would just call the dir “_blocks”
restricting access is a good goal, but given that there are already ways to do that easily, are there any other reasons to locate resources outside of the module directory?
#619 / Aug 13, 2008 11:29pm
yes, but it would be better if it organized into different folder, because if it’s not, it’ll look messy, 10 modules may be fine, more than that? i believe you’ll only get trouble because maybe some modules will have same model name or same controller name.
#620 / Aug 14, 2008 5:33am
sophistry
I think underscores and such is a bad idea. One little mistake and you can lose app security.
#621 / Aug 21, 2008 5:34am
Sorry, newbie question here. How would I go about converting a library into a module? Something like an Auth library that’s already been built. I’m not quite grasping the concept of Modules taking the place of Libraries…
>< Don’t hit me! hehe
#622 / Aug 21, 2008 8:28am
Welcome to the CI forums MeanStudios.
How would I go about converting a library into a module?
Simply create a application/modules/{your_module}/controllers directory, drop your library into this and then edit it so its class extends the Controller class.
It is now a module controller.
Good Luck. 😉
#623 / Aug 21, 2008 8:32am
Thank you!
And what if it has it’s own config file, where would I put that? /app/modules/{your_module}/config folder? Or is that a bad idea?
#624 / Aug 21, 2008 8:52am
Hi, again.
Yes every module may have its own config directory, modules use the same directory structure that CI uses for the main application.
#625 / Aug 21, 2008 9:22am
Mmm? The same directory structure? Can I use languages / libraries / helpers etc.?
#626 / Aug 21, 2008 10:09am
I’m a bit confused, sorry 😕. The library I’m trying to port over is CL_Auth (download here). I don’t want you do it for me, but maybe give me some tips? At the top is some functions that act like controllers. After those is the CL_Auth class. Would I take those top functions out of the file and then do?:
class CL_Core extends ControllerThen put those top functions in another controller file along with the functions that are in the auth.php controller file that comes with the download? And if I did that, would I do something like
$this->load->module('CL_Auth', 'cl_auth')$this->cl_auth->check().
I hope I haven’t exploaded your brain with stupid questions 😕. I can usually put things together with a lot of trial and error but this is hurting my brain heh.
#627 / Aug 21, 2008 11:36am
Mmm? The same directory structure? Can I use languages / libraries / helpers etc.?
Absolutely Sam.
#628 / Aug 21, 2008 11:44am
@MeanStudios,
Sorry I can’t help you code the module, But what you describe sounds feasible and just requires a bit of thought.
One point, $this->load->module(‘cl_core’); is all you need to load the controller. (any second var is passed to the module constructor)
Make sure the class name is Cl_core and the file name is the same.
#629 / Aug 21, 2008 12:01pm
I was *just* having trouble with the class name being different than the file name 😊. I think I’m close actually! I’m taking a lot of risks, but I’m learning a lot 😊. Thanks for the help.
#630 / Aug 21, 2008 12:45pm
If I wanted to use a function from a module in a view, how would I do that? I tried doing the
$this->load->module('cl_auth');but I’m getting this error:
A PHP Error was encountered
Severity: Notice
Message: Undefined property: CI_Loader::$cl_auth
Filename: templates/backend.php
Line Number: 20On line 20 I’m doing:
$this->cl_auth->isValidUser();