![]() |
Plugin System
Hi all.
I have never done a plugin system and I would like to here your thoughts/suggestions or read some articles/anything about how a plugin system should work or should be designed. The plugin system I'm talking about is like the one for a CMS or even Wordpress that of course extends the functionality of the program. Thanks |
I would also be very interested in this!
|
I think probably the best way to go about a plugin system is via hooks. But the plugin should work via a class file which is placed in a special pool folder for plugins. You would do something then like the following:
php Code:
Then in your code you would initiate this class if the hook is valid. All the comment data would then be forwarded to the construct in an array. You would then feed back the data as an array -- and all would be well, the comment would be posted! |
Thanks for answering Wildhoney.
I don't quite understand this :S Let's take an example of a CMS, where I make plugins to extend it's functionality, like say, news plugin, photogallery, blog... What I'm thinking on now, is have a folder (plugins) where all the plugin files go. Then the cms looks into that folder and knows what plugins I have and what I don't, well then, I have a plugin file (main.php or something) this file will contain a plugin class (ex. News), this class will have several methods like Install() - that will install the plugin (create a needed db, configure some stuff, etc), Configure(), render() - that will actually show the news, and it should be executed on the page where the news will be shown.... Am I right about this?? or is there better ways to do it. |
freenity: this interests me too, I don't really have much experience of how others do it, but here's how I do it in my cms -
PHP Code:
PHP Code:
PHP Code:
This method allows me to keep my core methods (textfield,textarea,etc.) in one place, but gives third parties the chance to 'extend' my class and call their own, i.e. PHP Code:
Hope this spurs some ideas :) |
thanks.
:) |
Well, this is my way of doing plugings - I write them like a standalone app - with their templates, classes etc.
I have a config file in which is described which plugin go to what page. (About - article, gallery - using gallery plugin). And I just make a plugin.php file that is loaded to the CMS, and it is using all the global vars. Example. CMS calling the plugin.php - PHP Code:
PHP Code:
PHP Code:
All "actions"- view, comment etc are seperate classes in which you define what is going to happen in that action - view - loads the selected article etc. I used to write all this in one big class - and it become ove bloated - one class had ~1200 lines. So this seems like a good thing - for now. If anybody has any suggestions - please suggest :) Critcism is always welcome. This could be modified to use the real MVC platform - like ZendFramework/Cake/Kohana ... |
A question on this subject, is this possible?
php Code:
|
Quote:
It worked :-) |
It is possible, if you look into Zends core - simmilar thing can be seen - I've seen simmilar things in Kohanas core - that is why the check for indexAction() or someAction() to be defined as "controllers".
Edit: LOL, same post time :) |
Nevermind again :-D
I just made a mistake in the include part .. :-) And yea, hehe we posted the same time :-D Although, I don't really understand your script :-O |
Quote:
|
Quote:
|
| All times are GMT. The time now is 06:30 PM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0