Making an addon...


Well-known member
Hello. So I want to know how to make an addon. Can someone make a tutorial on how to make an addon? I want to make an addon where it edits a template and puts code in it.


The most basic explanation I can give to start understanding the process of what is involved is the following:

XenForo uses templates. Some templates come with one or more hooks.
Using these hooks in a plugin allows you for example to inject your own custom template.
You can create new templates and link them to a plugin.
There needs to be a code event for this.

So, to create a plugin you need a listener file, with a class and a public function that uses that hook, which when it's that hook gets your template and injects it.

So the first step is to create a new add-on (plugin).

Then to create the php file.

Then to create a code event for that plugin, using the class and action from the php file.

Then to create the custom template.

And you're done.

You can now export the plugin, it will create an .xml file, which will include any settings, options, phrases, templates, the code events, etc. Just not your own .php file. So download that one too.
The .xml and .php file together zipped up is then your plugin for backup or distribution reasons.

To upgrade or install a plugin, you import the .xml file via the admin.php area, AFTER the .php file is put in place.
The .php file has to be within the library/ folder. Personally I like to anticipate that I might have more plugins, and organize them under library/XenFans/ for example, (replace xenfans with your own name for example) and within my parent folder I make a directory for each individual plugin. So if I have 2 plugins, 1 for the header, 1 for something else like a sidebar. I will have: library/XenFans/Header/ and library/XenFans/Sidebar/ This ensures me and others that it's easy to find my particular plugins, and that they don't class with existing files, and that uninstalling a plugin is as easy as uninstalling it from the admin.php area, and removing the child-directory of the plugin.