Hi all,
I have been writing some code that creates a generic blog.
Its features are simple, create a post, edit and delete the post and allow comments.
I am trying to write it so that it is very easy to write plugins for, however Im not sure on the best approach.
Some of my ideas:
Have the plugin author write a short script called e.g "config" in which they have an array that has the application(e.g frontend, admin etc), the module(e.g blog, profile etc) and the action(s)(e.g create, edit etc) that thier plugin affects, then include the plugin files when the correct action is run.
//example array in config.php: array( 'application' => 'admin', 'module' => 'blog', 'action' => array('create','edit') );
add strings into the views code such as "{form-extras}" and have the plugin author say which string there code will replace. Then use str_replace to replace the {xxx} with the plugin code.
#example code in blog_form.php <input type="text" name="blog_title" /> <input type="text" name="blog_text" /> {form-extras} #example code in plugins config.php array( 'replace' => array('form-extras') );
Both of these ideas are pretty rubbish and very limited in their use but I am struggling to come up with an better ideas.
I'm not sure how much info about my code people need but the basic dir structure is simple, below is an example:
apps //applications
frontend //app name
modules
blog
views
index.php //list blogs
new.php //create new blog post
actions.class.php
admin
modules
blog
views
index.php //list blogs
new.php //create new blog post
actions.class.php
lib //library of classes like database class
plugins //where plugins will hopefully be installed
web //where the site runs e.g index.php, all the css and js
The Question
Does anyone know of any tutorials/articles on making code easy to write plugins for, or does anyone have any tested methods that I could apply?
Regards
Luke