Welcome Guest, Not a member yet? Register   Sign In
Modular Extensions - Version 4.3

[eluser]Delete Me Please[/eluser]
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

[eluser]wiredesignz[/eluser]
Welcome to the CI forums MeanStudios.

Quote: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. Wink

[eluser]Delete Me Please[/eluser]
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?

[eluser]wiredesignz[/eluser]
Hi, again.

Yes every module may have its own config directory, modules use the same directory structure that CI uses for the main application.

[eluser]Sam Dark[/eluser]
Mmm? The same directory structure? Can I use languages / libraries / helpers etc.?

[eluser]Delete Me Please[/eluser]
I'm a bit confused, sorry Undecided. 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?:
Code:
class CL_Core extends Controller
Then 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
Code:
$this->load->module('CL_Auth', 'cl_auth')
in this other controller file so I could still do stuff like
Code:
$this->cl_auth->check()
.
I hope I haven't exploaded your brain with stupid questions Undecided. I can usually put things together with a lot of trial and error but this is hurting my brain heh.

[eluser]wiredesignz[/eluser]
[quote author="Sam Dark" date="1219339320"]Mmm? The same directory structure? Can I use languages / libraries / helpers etc.?[/quote]

Absolutely Sam.

[eluser]wiredesignz[/eluser]
@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.

[eluser]Delete Me Please[/eluser]
I was *just* having trouble with the class name being different than the file name Smile. I think I'm close actually! I'm taking a lot of risks, but I'm learning a lot Smile. Thanks for the help.

[eluser]Delete Me Please[/eluser]
If I wanted to use a function from a module in a view, how would I do that? I tried doing the
Code:
$this->load->module('cl_auth');
but I'm getting this error:
Code:
A PHP Error was encountered

Severity: Notice

Message: Undefined property: CI_Loader::$cl_auth

Filename: templates/backend.php

Line Number: 20

On line 20 I'm doing:
Code:
$this->cl_auth->isValidUser();




Theme © iAndrew 2016 - Forum software by © MyBB