Welcome Guest, Not a member yet? Register   Sign In
modules in CI?
#1

[eluser]Reynolds[/eluser]
it's been a long while, since I ask a question here at the forum Wink

when I came here at the forum, my question was to why would I use CI, and what are its pitfalls... still I end up using it... for a long while now Wink

Now, I happen to hit a project which will include multiple modules. I said "modules" as part of single-website (and same database), but independent to other modules (e.g. tables, and libraries, resources like images, js, and css).

I'm trying to find a way how to do just that with CI. However, I seem to not found it.... yet.

I would like one controller, on its own folder, along with a /view/ and /resources/ folders inside it.

For example.

I would like an "Inventory" Module;

/index.php
/system/
/modules/ <---- this is where I would like to put all modules


/modules/inventory/

/modules/inventory/views/

/modules/inventory/resources/
/modules/inventory/resources/images/
/modules/inventory/resources/js/
/modules/inventory/resources/css/
/modules/inventory/resources/includes/


the module(s) shares the same database, sessions, etc of the entire application. Also I would like to implement an autoloading of this modules. If a module is found within the /modules/ folder it will automatically load, and show it at the main workspace or dashboard as many calls it that way.

I looked at scaffolding, it seems similar to what I' thinking, coz it have its own and independent views, controller, and resources. But, before I destroy my copy of CI, I would really love to get the proper know-how for this.


Thanks Wink
#2

[eluser]sikkle[/eluser]
I think the only thing you need for that is to go into the wiki and forum, and look for modular extension.

This is what it does.

good luck!
#3

[eluser]Reynolds[/eluser]
my GOD! thank you Sooo much, after a few tries on some modular extension, i found MatchBox, more in a very little effort.

http://code.google.com/p/matchbox/
#4

[eluser]wiredesignz[/eluser]
When you have finished playing with Matchbox, take a look at Modular Extensions (see my signature) it has many additional features to help you work better with modules.
#5

[eluser]Reynolds[/eluser]
oh my GOSH!!!, now with matchbox, how do i use view and models?
#6

[eluser]Reynolds[/eluser]
controller (sample.php)
Code:
&lt;?php

class Sample extends Controller {

  function Sample()
  {

  }

  function index()
  {
    $this->load->view('sample_view');
  }


}
?&gt;


view (sample_view.php)
Code:
&lt;html&gt;
&lt;head&gt;&lt;/head&gt;
&lt;body&gt;<h1>Hello, from module!</h1>&lt;/body&gt;
&lt;/html&gt;

when i load the module, this is what happened

Code:
A PHP Error was encountered

Severity: Notice

Message: Undefined property: Sample::$load

Filename: controllers/sample.php

Line Number: 12

Fatal error: Call to a member function view() on a non-object in G:\codeigniter\glocorp-ci\application\default\modules\sample\controllers\sample.php on line 12
#7

[eluser]Reynolds[/eluser]
nevermind....

i changed to "Modular Extensions - HMVC" -- now im able to load views as well... now to test other resources...
#8

[eluser]wiredesignz[/eluser]
Good choice. Don't forget to initialize your controllers
Code:
&lt;?php

class Sample extends Controller {

  function Sample()
  {
    parent::Controller();   //iniiialize the controller.
  }

  function index()
  {
    $this->load->view('sample_view');
  }


}




Theme © iAndrew 2016 - Forum software by © MyBB