Welcome Guest, Not a member yet? Register   Sign In
SimpleModule v.1
#1

[eluser]AnimeCYC[/eluser]
Update 6/4/09

I've updated the code with a fully commented version, I did not replace the original simply because not everyone wants to see the comments. Hopefully reading through the library now it will make a bit more sense. If requested I will write a documentation as well.

--------------------------

Hey All,

I'm new here; I've been lingering around CodeIgniter for sometime now and have been in and out of using it, until recently when I finally decided to sit down with it and mess around. To test out CI I tried to develop a "no-frills" module loader, it only took me an hour to finish but I figured I would post is here to see what everyone else thinks and maybe get some feedback and requests for it. Here is the feature list.

SimpleModule v.1
Light Weight
Integrates easily for any application
Name/Version/Description control (optional)

Thats it! "No-frills" right? If you have any suggestions/comments/criticisms/requests let me know; Code with sample is attached. I want to apologize in advanced but I didn't comment the code except for a couple of things, if you want a fully commented library or if you have no idea how to use it by reading the sample module and controller let me know.
#2

[eluser]Phil Sturgeon[/eluser]
I can see some thought has gone into this but I'm not sure I follow. What is the purpose of this? Is it meant as a lightweight competitor to Matchbox and HMVC?

I'm not sure I like the way you load "a module" and it then loads the view automatically. Perhaps I don't understand.
#3

[eluser]Dam1an[/eluser]
I don't like the idea of auto loading the view as I've had problems with form validation when loading a view with the controller/function name (using a hook)
Also, can you have a view folder as you will normally have more then one view per controller
#4

[eluser]AnimeCYC[/eluser]
[quote author="Phil Sturgeon" date="1244121334"]I can see some thought has gone into this but I'm not sure I follow. What is the purpose of this? Is it meant as a lightweight competitor to Matchbox and HMVC?

I'm not sure I like the way you load "a module" and it then loads the view automatically. Perhaps I don't understand.[/quote]

To answer your question, I didn't think it would compare to a full fledged system as HVMC or Matchbox but ... maybe? As for the the view, it doesnt load the view automatically. This is optional by calling the $this->view(); method from within the module controller on the display() method for instance:

Code:
function display() {
  print $this->someFunction();
}
function somFunction() {
  $this->view('sampleView');
}

The function that the library looks for to output the display is the display() method inside the module controller so if you don't want anything to display either don't call the view() method from within the module controller or don't call the display() method within the module controller and set the load() method within its parent controller (where your calling the module from) to not buffer the result and it will just include the file instead of sending it to the output buffer.
#5

[eluser]AnimeCYC[/eluser]
[quote author="Dam1an" date="1244122019"]I don't like the idea of auto loading the view as I've had problems with form validation when loading a view with the controller/function name (using a hook)
Also, can you have a view folder as you will normally have more then one view per controller[/quote]

It does not automatically load the view, to load the the view you have to call the view() method from within the module controller. Also, yes you can have folders for your views, the views are relative to it's module folder. For instance:

Code:
function display() {
  $this->view('folder/sampleView');
}




Theme © iAndrew 2016 - Forum software by © MyBB