Please note that this documentation relates to Vanilla 1
The first thing you need to do when creating an extension is read about how Vanilla works. The Order of Execution document is a great place to start.
The second thing you need to do is come to terms with the fact that you will not EVER be altering ANY code in Vanilla. Most web programmers, especially PHP programmers, might find this hard to accept because they are used to making minor changes to applications. You can NOT do this with Vanilla because it will make upgrading very very difficult later on, and you definitely want to be able to upgrade quickly and easily in case bugs or security holes are discovered and patched.
The third thing you should do is go to http://lussumo.com/addons and make sure that your extension doesn’t already exist. If it does exist, but it doesn’t quite do what you want it to, you can contact the author about altering it, or even get that author’s permission to alter his/her code and make a branched version of his/her extension. Finally, it’s always a good idea to take a look at existing extensions just so that you have a unique name for your extension. Since all extensions sit in the extensions folder, you don’t want to use a folder name that has already been taken by another extension.
So, you’ve read all about how Vanilla works and now you want to add something to it. It doesn’t really matter what you want to do, we will find a way to do it. So, first things first, let’s make your basic extension file. Extension files are all located within vanilla’s extensions folder. If you take a look in this folder you’ll see that all of the extensions have a folder of their own. Even if your extension is just a single file, it should still sit within it’s own folder. So, create a new folder named after your extension (and remember to make sure it is unique so that it doesn’t clash with other extensions).
Within your new folder, create a default.php file. This is the main file that will be included by Vanilla when your extension is enabled. The first few lines of this file are used by Vanilla to display information about your extension on the extension management list.
Any extension MUST contain this information at the top of the file:
<?php /* Extension Name: Your Extension Name Here Extension Url: The url to where this extension can be downloaded Description: A description of your extension Version: The current version of your extension Author: Your Name Author Url: Your personal url */ ?>
Once you’ve specified this information and saved your file, you could go into Vanilla and take a look at the extension management list and you would see your extension show up there. Enabling it at this point would do nothing, of course.
The sky is the limit with Vanilla, but depending on what you want to do, there are various different methods for how to do them.
The main thing you should be aware of is that many controls in the base version of Vanilla already have convenience methods in place that you can use to do a variety of tasks. Here are a few examples...
If you want to be able to format user comments in a new way, you should read about String Formatters.
But that’s just the beginning. Vanilla has a little something built into its core called “Delegation”.
Delegation definitely deserves it's own page, but here is a quick summary of Delegation and how it works:
Littered throughout Vanilla are 176 (as of the time of this writing) delegates, and more are added all the time. Delegates can be called from within a control like so:
The name of the delegate that is called (in this case it is “PreRender”) is completely arbitrary and made up. The point is that each delegate is unique to the control in which it sits. As an extension author, if you know the name of a control, and an instance of this “CallDelegate” method within that control, you can write a function that gets executed at that delegate’s position within the control, allowing you to do anything to that control and it’s properties, or even render things to the screen.
If you want to know more about how Delegation works and see some examples (and you definitely should), check out the page on Delegation in Vanilla.
There are many other things to learn about developing extensions for Vanilla. I highly recommend that you read all of the documents under the “Developing New Extensions” heading of this documentation site. To whet your appetite, here are a few other things that you can do with Vanilla: