I'm looking for ways to implement a module system into my application framework, Modules would be class files that change the design in some way so that the would automatically integrate with user intervention.
My framework is a custom built framework but is very similar to codeigniter, just a little lighter.
The idea that I have is within the template files is to call on module positions, and have modules auto loaded and parsed
<html>
<head>
<title>Welcome to my site</title>
</head>
<body>
<header>
....
<?php $this->call_modules('header') ?>;
</header>
<section>
<aside>
<?php $this->call_modules('sidebar') ?>;
</aside>
</section>
</body>
</html>
So that the following modules would get called and the contents would go in there place:
/system/applications/admin/modules/header/a.php
/system/applications/admin/modules/header/b.php
/system/applications/admin/modules/sidebar/a.php
/system/applications/admin/modules/sidebar/b.php
So that to me seems like it would work fine, but the problem is that I have never built a module system before, and I feel as these are more classed as hooks.
In my head i basically want a simple system that consists of 1 class file, and templates if required, the calss file would probably look like this:
class Module_HelloWorld extends Module
{
public static function info()
{
return array(
'name' => 'Hello Word',
'version' => '1.0.0',
'description' => 'Dispalys "hello World"',
'author' => 'Robert Pitt',
);
}
public function execute($context,$action)
{
//$context would be the current view at the point of execution for the view
//$action would be header / sidebar
}
}
So my question in a nutshell, What would be the best way to design a module system for my framework, allowing 3Rd party modules to be dropped within a directory and then installed from admin, without much user intervention?
good luck with your mvc and cms. I have implemented same think some time ago, my approach was simple the first one came to my mind.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With