Making addons

Morgain

Well-known member
... start learning how to code? Like that you can code your own add ons and problem is solved. Just an idea really.

borbole (and anyone else) I would so love to make my own little addons. But I don't know where to go next.
I can do html and (with a struggle and looking it up) CSS.
I know enough about php to be able to tweak it without mucking it up.
I know my way around XF phrases, and templates. I can create a new template and insert it.

Where next? Learn php properly?
There are also these mysterious hooks and listeners.

Any pointers, links, tips welcome.
 
Before I started using XenForo, I was much like you, Morgain.

I had tweaked PHP briefly once before. I have no experience with programming in any other language (other than basic scripting languages).

So I had to start somewhere.

My first add-on was (and still is, actually, I must sort it out :D) crap. It was 99.9% coded by Jake and I just tweaked it.

Then I did a load of TMS dependent add-ons.

But I was really beginning to get interested in the PHP behind XenForo. So I began here:

http://xenforo.com/community/resour...-insert-tabs-in-profile-page-using-hooks.335/


If you do the same, you should be able to produce a basic add-on by the end of it.
 
Thanks yes a good start.

Before I started using XenForo, I was much like you, Morgain.
Immensely encouraging Chris as you're one of the really good ones.
I will check out the link you gave as Lawrence's tutorial already has me boggled.

First advice I would offer....
You need to know what you want to make first...otherwise you are flying blind trying to catch a bearing.
Good advice ---- Oh lots of things!
The one I real.ly NEED is to add a short list of users to a forum, then members using the forum can select one from a list to receive notification (textboxes). But if not selected you don't get notified even if you are on that thread already.
(I had this on another type of forum software and it was great for mod support work)

It might be too ambitious as a start.
But I guess breaking it down I need to

- add option to forum permissions;
- this disables the general notifications function ie if you Reply you DO NOT automatically get notified.
- admin form to select users to add to this forum who CAN be notified;
- form includes a label for text describing each user to aid selection on a post.
- create function that this forum option notifies one or more of the listed users;
- form which adds to the post displays the list of user recipients with textboxes.

Is this too ambitious for a starter project? (it's what I urgently need)
and if possible for me, can you suggest a better worklist? that is sequence of task
 
I'm happy coding stuff with PHP (can also do stuff with Perl/Bash, and use them all in my day job at work), and I taught myself from books (mainly the O'Reilly sets), but I can't quite get my head around the MVC framework at the minute.
 
A decent IDE where you can jump to declarations and has autocomplete (eg phped, phpstorm) is invaluable for learning the xenforo system

Overall it's easy enough to get your head around, especially since the template hook system was added. Development for 1.0.x was a bit of a nightmare by comparison :P
 
A decent IDE where you can jump to declarations and has autocomplete (eg phped, phpstorm) is invaluable for learning the xenforo system
What on EARTH was that about? Is that a type of program we should get?
What's an IDE? What kind of "jump?" What autocomplete? What is phped? phpstorm?

Please bear in mind this thread is for studying the very first steps in making an addon. So if you use ANY word outside of standard English, or very basic XF like "frontend" "admincp" either define and explain it, or recognise you are talking on a too advanced level.
This isn't a discussion between developers on preferred tools. It's a FIRST STEPS guide thread.
 
IDE stands for Integrated Development Environment.

PhpEd (I use this one), PHP Storm are both PHP IDEs. On a basic level they are text editors for PHP files. But they include specific PHP related functionality such as automatic code completion (e.g. if you type str_ it will automatically list functions that begin with the letters str_).

It also allows you to do things like click on a variable in your code and it will jump up to where it was first defined, for example.

It will often highlight basic errors in the code too.
 
IDE stands for Integrated Development Environment.

PhpEd (I use this one), PHP Storm are both PHP IDEs. On a basic level they are text editors for PHP files. But they include specific PHP related functionality such as automatic code completion (e.g. if you type str_ it will automatically list functions that begin with the letters str_).

It also allows you to do things like click on a variable in your code and it will jump up to where it was first defined, for example.

It will often highlight basic errors in the code too.
I'm just downloading the trial of PhpEd now. I'm used to coding in VIM directly on the server
vim.webp
 
I can follow the steps in Lawrence and Fuhrmann's tutorials and I can see myself doing them to completion. It still doesn't make sense though so I would not be able to go on and make my own - I'd just be blindly doing the obey thing like inserting a code snippet.
I don't cope well with videos like Kier's because as soon as I don't understand a detail unlike reading I can't easily re read back, or copy/ paste anmd rearrange until I get it. Hate tutorial videos!

I need to understand what hooks and listeners do. It seems to resemble how I create a new template, then put an insert command.
One thing sits there until it is called by the other.
So is the hook like a flashing signal that the Listener reacts to?
So IF the template with the hook is loaded,
AND a user clicks something in that hook's territory of code,
THEN the Listener contributes its payload.
Is that right?
 
Imho I do not think that you would need an IDE, at least for now. You can start with a decent php editor program like notepad++ for example.

You would know at least the basics of php and OOP. You should be aware though that this will require patience and lots of free time, but mostly the former :D

If I were you I would start with something small, like following the guide by Lawrence here:

http://xenforo.com/community/threads/creating-an-addon.5416/

You can try and make that mod. If you will run into difficulties do not give up but keep going. One learns through trials and errors. Then you can start by creating another simple mod like inserting something in the templates for example.

Another tip that I would give you is to download the free mods and study them. That would help you a lot. If you will have questions, do not be shy to ask. There are quite a lot of helpful users and talented coders here that help out.

And last but not least, my congratulations on your initiative :)
 
I'm happy coding stuff with PHP (can also do stuff with Perl/Bash, and use them all in my day job at work), and I taught myself from books (mainly the O'Reilly sets), but I can't quite get my head around the MVC framework at the minute.
Well I took some initiative last night during a quiet shift at work, and managed to finally convert a custom page that I did for my old phpBB3 forum. What was holding me back was figuring how to query the database to pass the results into a page node.

It's really simply, and there is probably a better way of doing it, but stuck with it and got it to work in the end

CallBack
PHP:
<?php
class PowerBoard_PowerBoard
{
    public static function getPowerBoard(XenForo_ControllerPublic_Abstract $controller, XenForo_ControllerResponse_Abstract &$respon
se)
    {
        $db = XenForo_Application::getDb();
 
        $supercharged = $db->fetchAll("SELECT * FROM xf_powerboard WHERE pb_type = 'Supercharged' ORDER BY pb_power DESC");
        $na = $db->fetchAll("SELECT * FROM xf_powerboard WHERE pb_type = 'NA' ORDER BY pb_power DESC");
        $tub = $db->fetchAll("SELECT * FROM xf_powerboard WHERE pb_type = 'Turbo' ORDER BY pb_power DESC");
        $auto = $db->fetchAll("SELECT * FROM xf_powerboard WHERE pb_type = 'Auto' ORDER BY pb_power DESC");
 
                $params = array (
                        'supercharged' => $supercharged,
                        'na' => $na,
                        'tub' => $tub,
                        'auto' => $auto
                );
 
                $response->params = array_merge(
                        $response->params,
                        $params
                );
    }
}
?>

and the template html
HTML:
<style type="text/css">
.outercontainer {
border: 1px solid #c6c5c5;
border-radius: 5px;
box-shadow: 0 0 5px #d2d2d2 inset;
padding: 10px;
margin: 0 auto;
background-color: #f4f3f2;
}
</style>
 
<div class="outercontainer">
<div class="baseHtml">
<h3>Supercharged</h3>
<ol>
<xen:foreach loop="$supercharged" value="$supercharged">
<li>{$supercharged.pb_username} = {$supercharged.pb_power} bhp - {$supercharged.pb_notes}</li>
</xen:foreach>
</ol>
<h3>Naturally Aspirated</h3>
<ol>
<xen:foreach loop="$na" value="$natas">
<li>{$natas.pb_username} = {$natas.pb_power} bhp - {$natas.pb_notes}</li>
</xen:foreach>
</ol>
<h3>Turbo</h3>
<ol>
<xen:foreach loop="$tub" value="$tuby">
<li>{$tuby.pb_username} = {$tuby.pb_power} bhp - {$tuby.pb_notes}</li>
</xen:foreach>
</ol>
<h3>Automatic Transmission</h3>
<ol>
<xen:foreach loop="$auto" value="$autot">
<li>{$autot.pb_username} = {$autot.pb_power} bhp - {$autot.pb_notes}</li>
</xen:foreach>
</ol>
<p>To have your results added to the above list, please contact Matt who will add the details for you</p>
</div>
</div>

again, I'm not sure if there is a cleaner way of doing it, but it's working, and it's not got a lot of results to go through in the DB.

Now.....to try and figure how to add to the database :whistle:

Oh, and the book collection I have at work I mentioned previously
2012-12-27 20.48.49.webp
 
Top Bottom