How to create an addon tutorial part#1
The Starter's Guide
Will add more parts as time allows
This tutorial assumes you are not too familiar with xenforo platform, but it does assume that you are an experienced developer and that you are familiar with the MVC Model.
I know there is already a "how to" create an addon tutorial some where. When I was new to xenforo it wasn't at all clear to me. It assumed I was already familiar with the xenforo platform.
Thankfully with the help of my friend Jeremy (Jeremy_P here on the forums), I was able to dig into the code and went to him for immediate questions.
If you are one of these developers who isn't too in depth into the code, or you are a new developer to xenforo this is for you to get your toes wet. I also noticed these migrating from vbulletin already posses some background on how the platform works, nonetheless I hope many of you find this tutorial useful.
Be sure to like it.
So this new tutorial is directed to developers who are not as familiar how the xenforo platform/framework works.
1. Abstracts/Overall Overview
The abstracts is the none technical information directed to help you understand better how to start building your own addon.
In the overall, we are going to focus on a "Hello_World" addon, so that you can relate more.
Some of the core tips:
- Xenforo users extensive assistance from the Administration UI to create addons. This can be very tedious, annoying and painful at first if you are not used to this. But once you find your way around it becomes all clear.
- The library directory is your home directory as a xenforo developer. Every addon or custom modification you do, will go in here.
- Each addon has it's own directory in the library directory. So if you create an addon you will need to create a directory here.
- The naming of the classes represent the path directory of each file (with exception of the library directy). Eg. If you want to call a class it is always consistent, "YourAddonDictory_FileName" so in this fake class, your file would be in the library directory as "library/Hello_World/FileName.php" and assumes "FileName.php" has a class with the name "YourAddonDictory_FileName".
- You may use assistance from the rest of the xenforo's classes and existing code by using the same logic. There is a xenforo directory inside the the library directory, and the same applies here. So if you need assistance to create a thread or message, or any of these every day tasks xenforo already does, you make the use of classes through the xenforo framework. In this example "xenforo_subdirectory_file" would look for a file in "library/xenforo/subdirectory/file.php". Within the xenforo directory everything is categorized properly so you can easily locate anything that you may need. Eg. If you want to do something related with users and data, you can easily assume to look into a file "Xenforo/Model/User.php", something dealing with threads and data, would go to "Xenforo/Model/Thread.php" and so on.
- Use XenForo_Model::create($class); to create a new class. Eg. XenForo_Model::create("Hello_World_Model_File"); (would locate a file in "library/Hello_World/Model/File.php")