Page 1 of 1

Making a modificaton system?

Posted: Thu Jul 05, 2007 5:09 pm
by toasty2
What would you suggest for making my code where people can make modules/modifications for it? I'm wanting to implement a module system for my CMS that I'm writing.

So far I have:

Code: Select all

$mods = @opendir('mods') or die(getError(2));
while ($file = readdir($mods)) 
{
	if($file!='.' and $file!='..' and $file!='index.php' and strpos($file,'.php'))
	{
		include 'mods/'.$file;
	}
}
closedir($mods);
But, this method obviously has limitations and people can't really modify my code except for adding to it.

Posted: Thu Jul 05, 2007 6:14 pm
by Ambush Commander
It looks like your CMS is in transaction script style. I suggest you first look into adding hooks at key points of execution.

Posted: Thu Jul 05, 2007 6:15 pm
by alex.barylski
What do you have? Doesn't really look like a module system. :P

Look into every known, existing open source CMS and at least 90% of them implement some kind of module system, all with their positives and negatives.

Essentially, modules range from simple extensions, like breadcrumb generators to complex mini-applications, such as realty listings module.

Depends on what kind of functionality you want ot offer in your CMS?

For a complex mini-app enhancement you want to implement your module system similar to ASP.NET using something like MVP/MVC pattern. Each module is repsonsible for generating it's own view, handling controller logic and model data. Personally I have most of these systems to limiting, dictating what they consider either good design or similar (either at GUI interface level or implementation level). Many modules are also, likely best implemented as a core part of the system, like login modules. Ick.

As you can see, things can get complicated quickly and how flexible the system is you implement really depends on your requirements.