"Modulization"! - Adding Plugins to SimBlog

What happened?

I added a new system of managing blog plugins, which is widely used in places like WordPress. I will explain the reason why and the implementation briefly.

Code Duplication

SimBlog uses MVC framework, when we visit a page, it has to go through the controller. This framework is good at avoiding code duplication, but there is still room to improve.

Let's say if we want to display a "Recent Post" sidebar menu on the main page, we need to put those lines of code in the main page controller, to collect the data, choose the HTML template and render it on the page. If we want to do that on our post page, we will need to place those lines of code in the post controller too.

This means code duplication on every controller that we use this widget. 

Difficult to Manage

As mentioned above, same piece of codes are on different controller, if there is change to the widget, we would have to go through all the controllers to find them. It would be nice to have them in a central location. The same applies to widget removal!

Not Ideal for Other Developers

It would be very difficult for someone to share their own invention, like a nice "world map widget" on the sidebar, or a "fancy looking comment form" under each post. They would have to share the whole controller file, or even all the blog PHP scripts. 


That's why we introduced plugin system in SimBlog. Plugins are all in side a folder, each plugin folder contains a PHP source code and a HTML template. SimBlog also provides a very clean web interface to manage plugins:

By simply turn the plugin ON or OFF, it adds/removes the plugin from the blog. 

Here is an example: I don't like the category side bar widget, and I want to remove it.

Let's go into plugin manager, locate where the plugin is and turn it off.

Go back to the main page and check, it's now gone :)

The plugin system still needs to be tested for bugs, and I shall write an tutorial on it soon.