Hey everyone,
I'm currently working on a redesign of a project I am planning to get at least mostly finished (I'm not making anything super-ambitious, don't worry) by the end of this summer. The project is a simple, custom (that's the reason why I'm even making something like this when there are many other options,) CMS project. The project actually started two summer's ago, but it was more like a more simple clone of the old PHPNuke mixed with blogging ideas.
Anyway, I am wanting to get away from the way PHPNuke handled modules (extra functionality for the future.) The way that it worked (in the version I used to use, I'm not sure how it or PostNuke work now though,) was one would have two folders: "case" and "modules". Then, there was a variable called "op". When there was a need to do something, like list users on a page, or show an article, etc. you would use the op variable to go grab the function you wanted to call (in a module usually.)
That method works okay, but I want to make the "module" idea a bit different. And after seeing how Drupal manages modules, I had an idea to use a MySQL table (in addition to the other tables I have for the CMS database,) to store what modules are found or located in a specified folder--and if the module is enabled or not. The table part is easy to do, that's not the question I'm asking here.
The question I am asking is more like a request. I made a simple flow chart of ideas of how my idea for modules would work. I want to know how unefficient it is, and if there is a better way to enable modules to be used in a CMS type PHP program. By the way, for clarification, a module is basically a set of functions specific to the purpose of a module.
Flow Chart:
Check a directory for Modules → (modules not found, so break)
↓
(modules found)
↓
Put all module filenames into an array
↓
LOOP: compare modules in folder (via the filenames array with modules that are listed in the module table in MySQL database → (if module listed.. do something..)
↓
(if module isn't already listed)
↓
Insert module name into database table (and set it's enabled value to 0 (off) as a default)
And then, I was thinking, I will have to check the module table in the database, to check to see what modules are enabled (when browsing the CMS) and then, if a module is enabled, then make that a require() file ... but isn't this method going to be a bit slow? Is there a more efficient way to handle modules for a simple CMS?
Thank you for any advice, pointers, comments or criticisms.
Andy