LnBlog stores all its plugins in a "plugins" directory. The plugins directory stores all the plugins that are present in an LnBlog installation. It may contain one or more subdirectories with names like "disabled" to store plugins which are not to be loaded.
The plugin mechanism is really quite simple. LnBlog LnBlog maintains two lists of plugins: disabled plugins (i.e. those that should not loaded) and plugins to should be loaded first. These lists can be set for the entire installation and can also be overridden for individual blogs. You can edit these lists through the "configure plugin loading" link.
When a page is loaded, LnBlog will do the following. - Looks at the plugins directory (subdirectories are ignored) to get a list of all the PHP files that are present. - Sort the plugins based on the order set in the "configure plugin loading" page (the default order is alphabetical). - Removes any that are marked as disabled. - Initialize each plugin that's left, in order, by including its file.
For plugins that write user-visible data, e.g. sidebar panels, the order in which they are loaded is important. For example, the sidebar panels are displayed in the order in which they are loaded. If you want to change the order in which the sidebar panels appear, then you should change the order in which those plugins are loaded.
Adding a new plugins is as simple as copying the plugin PHP file into the plugins directory. If a plugin requires any additional installation steps, it should be noted in the plugin documentation.
It is also possible to install plugins on a per-blog basis. To do this, create a directory named "plugins" in the blog root directory and copy the plugin file there.
To disable a plugin, go to the plugin loading configuration page and uncheck the "enabled" box for that plugin file. To uninstall a plugin, just delete the file or move it out of the plugins directory.
As previously noted, load order is important for plugins that add segments to the page, such as sidebar plugins. To change this order, go to the plugin loading configuration page and use drag-and-drop to sort the files to reflect your desired order. Don't forget to submit the form to make your changes take effect.
LnBlog uses an event-based plugin system. That means that LnBlog sends out messages when certain things happen, such as a page being displayed or an entry being added. Plugins work by registering themselves with the event manager and asking to be run when certain events are fired.
The actual coding of a plugin can be done in several ways. The recommended method is to create a class for your plugin which inherits from the abstract Plugin class, as this will allow you to inherit certain basic functionality. Beyond that, it depends on what you want to do. The back-end classes mostly allow for auto-detection of identifiers, so, for example, you can simply do something like
$myblog = NewBlog();
to get access to information on the current weblog. The same thing works for entries and articles, although individual comments generally need an explicit identifier. Of course, it is always possible to simply create an instance of the parent entry of a comment and get a list of comments that way.
The plugins/disabled directory of the default LnBlog installation includes a template.php file. This is a heavily commented plugin template which is intended as a learning tool. Between this and the standard set of plugins, it should be possible to get a good idea of how the plugin system works.