CMS Module Loader
Moderator: General Moderators
-
Touchstone57
- Forum Newbie
- Posts: 5
- Joined: Tue Dec 28, 2010 2:59 pm
CMS Module Loader
Hello there,
So at the moment I'm developing my own CMS (of sorts). So what I want is to make it flexible and utilise OOP, so I that I have a modular system where I can drop modules in and out to provide the functionality.
I'm just having a little difficulty in figuring out how I would start loading modules. I know I would create some sort of module loader, but having difficulty in conceptualising what it should have.
So at the moment I do have some of the functionality for the CMS (database classes, user classes, login etc) but merely in stand alone classes. I want to incorporate the functionality into modules which can be loaded and easily extend the system if need be.
So can anyone point me in the right direction to where I could start?
Thanks!
So at the moment I'm developing my own CMS (of sorts). So what I want is to make it flexible and utilise OOP, so I that I have a modular system where I can drop modules in and out to provide the functionality.
I'm just having a little difficulty in figuring out how I would start loading modules. I know I would create some sort of module loader, but having difficulty in conceptualising what it should have.
So at the moment I do have some of the functionality for the CMS (database classes, user classes, login etc) but merely in stand alone classes. I want to incorporate the functionality into modules which can be loaded and easily extend the system if need be.
So can anyone point me in the right direction to where I could start?
Thanks!
-
Touchstone57
- Forum Newbie
- Posts: 5
- Joined: Tue Dec 28, 2010 2:59 pm
Re: CMS Module Loader
Any ideas? Or is this in the wrong section?
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: CMS Module Loader
Can you give examples of what you consider modules? How do you want them added? And, what services do you want these modules to get from the base application?
(#10850)
-
Touchstone57
- Forum Newbie
- Posts: 5
- Joined: Tue Dec 28, 2010 2:59 pm
Re: CMS Module Loader
Okay to get a very general idea of the site structure.
---- + Website/
-------- + library/
---------------- >Database.php (Handles database connection and queries)
---------------- >Template.php (Generates the web pages)
---------------- > Boostrap.php (Loads the models)
-------- + Modules/
------------ + Search/
-------------------- > Search.module.php
-------------------- >other stuff....
------------ + User/
-------------------- > User.module.php
So I'm hoping the the modules would carry out the core functions of the site. So adding the search module would allow you to perform searches in the database, and provide the graphics for it. The modules would use stuff in the core (library). Hope that makes sense. I think I wont have too much trouble with the functionality its just getting the right structure out.
I'm having difficulty in figuring out how the bootstrapping works. So that I can load the modules I need in the bootstrap, and figure out how to be selective about which modules to use.
Any help is greatly appreciated!
---- + Website/
-------- + library/
---------------- >Database.php (Handles database connection and queries)
---------------- >Template.php (Generates the web pages)
---------------- > Boostrap.php (Loads the models)
-------- + Modules/
------------ + Search/
-------------------- > Search.module.php
-------------------- >other stuff....
------------ + User/
-------------------- > User.module.php
So I'm hoping the the modules would carry out the core functions of the site. So adding the search module would allow you to perform searches in the database, and provide the graphics for it. The modules would use stuff in the core (library). Hope that makes sense. I think I wont have too much trouble with the functionality its just getting the right structure out.
I'm having difficulty in figuring out how the bootstrapping works. So that I can load the modules I need in the bootstrap, and figure out how to be selective about which modules to use.
Any help is greatly appreciated!
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: CMS Module Loader
It really sounds like your 'modules' are Controllers in the MVC sense.
(#10850)
Re: CMS Module Loader
There are different styles of modules
Modules that simply drop in and add new controllers (that don't change existing behavior, or alter existing behavior)
Then there's systems that do the above but let your new module drop in in place of an existing module (Ex. replacing the "article" manager in Joomla)
Then there's systems that lets modules modify other modules (Drupal modules can insert elements into other module's forms)
Then there's systems that let you override classes, so for example instead of instantiating Built_In_ShoppingCart you'd create an XML manifest that tells the system to instantiate Overriden_ShoppingCart everywhere where it would have otherwise instantiated the built in class. (Factory Pattern + Plugin Pattern) / Example - Magento
Then there's systems that let you write "plugins" (Ex. Your code tells the system: "run this function prior to user login" The system defines some "rule" like if it returns true log them in, if it returns false log them out) - Example Magento's "listeners" these implement the Plugin + Observer design patterns.
All of these are implementing the "plugin" design pattern, which at it's simplest means you have some file a developer can modify, that causes the system to "see" the new code.
Modules that simply drop in and add new controllers (that don't change existing behavior, or alter existing behavior)
Then there's systems that do the above but let your new module drop in in place of an existing module (Ex. replacing the "article" manager in Joomla)
Then there's systems that lets modules modify other modules (Drupal modules can insert elements into other module's forms)
Then there's systems that let you override classes, so for example instead of instantiating Built_In_ShoppingCart you'd create an XML manifest that tells the system to instantiate Overriden_ShoppingCart everywhere where it would have otherwise instantiated the built in class. (Factory Pattern + Plugin Pattern) / Example - Magento
Then there's systems that let you write "plugins" (Ex. Your code tells the system: "run this function prior to user login" The system defines some "rule" like if it returns true log them in, if it returns false log them out) - Example Magento's "listeners" these implement the Plugin + Observer design patterns.
All of these are implementing the "plugin" design pattern, which at it's simplest means you have some file a developer can modify, that causes the system to "see" the new code.
-
Touchstone57
- Forum Newbie
- Posts: 5
- Joined: Tue Dec 28, 2010 2:59 pm
Re: CMS Module Loader
Okay what would you recommend for the 'plugin' design pattern?
I guess it would be an MVC controller in a sense. So I'm wandering how I can get something very simplistic out that can 'see' the modules and use their functionality?
I have spent a very long time looking at MVC stuff on the web and Drupal but its far too complicated in helping me develop my own...
Thanks.
I guess it would be an MVC controller in a sense. So I'm wandering how I can get something very simplistic out that can 'see' the modules and use their functionality?
I have spent a very long time looking at MVC stuff on the web and Drupal but its far too complicated in helping me develop my own...
Thanks.
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: CMS Module Loader
Well if they were Controllers then when you installed Search you could then do the URL 'mysite.com/search/'. If it was not installed you would get an error page.
(#10850)
- greyhoundcode
- Forum Regular
- Posts: 613
- Joined: Mon Feb 11, 2008 4:22 am
Re: CMS Module Loader
Looking at plugins in the context of WordPress, each plugin is (typically) contained within its own directory. The "main" file within that directory will contain some meta data that provides WordPress with information about what the plugin does, who made it, what version, etc.
Installing the plugin is simply a matter of copying the plugin files and dropping them into the WordPress plugins directory.
With that done, an administrator can look through all the available plugins, see who made them and what they do, and decide to "activate" or "deactivate" them.
Of course, if you want them to be instantly "active" without the need for administrator intervention then something different is going to be needed, but given that you are discussing a CMS I thought this might be a good example.
Installing the plugin is simply a matter of copying the plugin files and dropping them into the WordPress plugins directory.
With that done, an administrator can look through all the available plugins, see who made them and what they do, and decide to "activate" or "deactivate" them.
Of course, if you want them to be instantly "active" without the need for administrator intervention then something different is going to be needed, but given that you are discussing a CMS I thought this might be a good example.
-
Touchstone57
- Forum Newbie
- Posts: 5
- Joined: Tue Dec 28, 2010 2:59 pm
Re: CMS Module Loader
Hey thanks for your help.
So looking a Wordpress it seems like a much simpler system and better for my purposed. Though of course I'm still finding it difficult go get it started though.
One think I'm wandering is how exactly you can you activate and deactivate plug-ins without changing the files or the database?
I'm hoping to get some very basic stuff we can I load in something something like a login module and work from there. Any ideas?
So at moment I have index.php which loads the boostrap which loads everything else of course, but then...
Thanks.
So looking a Wordpress it seems like a much simpler system and better for my purposed. Though of course I'm still finding it difficult go get it started though.
One think I'm wandering is how exactly you can you activate and deactivate plug-ins without changing the files or the database?
I'm hoping to get some very basic stuff we can I load in something something like a login module and work from there. Any ideas?
So at moment I have index.php which loads the boostrap which loads everything else of course, but then...
Thanks.
Re: CMS Module Loader
What makes you think Wordpress doesn't? Better yet why would you even ponder this? What's wrong with storing things in a database?Touchstone57 wrote:One think I'm wandering is how exactly you can you activate and deactivate plug-ins without changing the files or the database?
Wordpress' plugin system uses the "plugin" & "observer" design pattern. The fact you create meta-data to tell it your plugin exists makes it a plugin. The fact you can setup callback functions makes it the observer design pattern as well. (Example there is a callback that gets called when users' run a search, and the array your callback returns gets unioned onto the end of the search results)
- greyhoundcode
- Forum Regular
- Posts: 613
- Joined: Mon Feb 11, 2008 4:22 am
Re: CMS Module Loader
In the case of WordPress the filepaths of each active plugin are held in an array. That array is then serialized and saved in a database table, in this case the options table.Touchstone57 wrote:One think I'm wandering is how exactly you can you activate and deactivate plug-ins without changing the files or the database?
Each time WordPress runs that serialized data is extracted from the options table and turned back into an array, which is how it knows which plugins to "run" - simply by iterating through the array and including the relevant files.