CodeIgniter Forums
Plugin or Widget - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: Best Practices (https://forum.codeigniter.com/forumdisplay.php?fid=12)
+--- Thread: Plugin or Widget (/showthread.php?tid=35)



Plugin or Widget - Rufnex - 10-25-2014

Hi there,

anyone arround how has a concept for plugins or widgets like WP for a CI project.

greetings
Rufnex


RE: Plugin or Widget - Shawn P - 10-26-2014

The guy that did HMVC (wiredesignz) has a widget add-in. I don't know if it's what you want, but doing the rest of it can be done from a database. So you could technically build out the "sidebar name" with widgets in it. Than just load that into the page.

https://ellislab.com/forums/viewthread/109584/P15/#633913

As for plugins, ideally I think if you have HMVC would be best. Than you can just have modules as your form of plugins. Again build a database to store information in it or an xml file so the modules can be version-ed. Than if you want to go the level of wordpress you would just need to communicate with your own database of existing plugins. Download the zip file build an extraction process that would install the "module" Not that hard to do, but would take a bit of time to refine it.

Way I would most likely do this would be to have a folder structure on my main plugin database system. So really the plugin system will read this folder structure remotely using cURL for example. Than in each plugin folder would be a latest version file, and probably folders for each version that's available. So if a user is at say Version 1 of a module. and version 1.1 and 1.2 is out they can update to 1.1 or 1.2. Not forcing them to update straight to 1.2. Once what version they update to is determined the remote system will find the correct zip file and download it. Than you can write the extraction routine on the local system, and update the version on the local system. Smile

The more complex part might be to build a database updating routine. Say a plugin requires table updates. So the new version of the plugin would have to include some sql commands to update the database. So you probably should come up with a standard structure and function that will handle that aspect. So that each plugin is designed a specific way.


RE: Plugin or Widget - robinleathal - 10-28-2014

HMVC (wiredesignz) makes life very easy for developers.


RE: Plugin or Widget - Hobbes - 10-29-2014

I personally use a widget system. The one i use was originally created by u.farooq. It is very similar to a module but allot thinner and is meant to be run right from your views.

in this system a widget has it's own views and models. and would be accessed like this in your view file:

PHP Code:
$data = array('var1' => 'hello''var2' => 'world');
$this->load->widget('test');
$this->test->run($data); 

it is a rather simplistic but powerful widget system.

---
for plugins i use Modular CI made by WanWizard.