XenForo...

Liam W

in memoriam 1998-2020
I didn't think I liked XenForo - I refused to use anything other than vBulletin until an hour or so ago ;-)

I have now decided, after looking over this forum for a while, that I like XenForo.

Just a quick question though, how are mods made? In VB 4, they are just php code run at hooks at places in the code. This was really easy. vB5 looks more like the WHMCS system, which I find complex and confusing.

So what is the XenForo system?

Also, I was in doubt as to where to post this so I posted it in off topic (if in doubt, it's off topic ;)).

Liam
 
Best place is probably pre-sales if your still considering xenforo and you haven't purchased yet.

Edit: one of the advance coders is probably better suited to answer your query so I'll leave that one for them. :)
 
Best place is probably pre-sales if your still considering xenforo and you haven't purchased yet.

Edit: one of the advance coders is probably better suited to answer your query so I'll leave that one for them. :)

(Was looking for the quote button then)

Well, I was going to say that first impressions weren't good, however the subscription email didn't contain your edit obviously, which made it much better ;-)

(Before the edit, you came across as unfriendly. It's a amazing what a smiley can do ;))
 
I didn't think I liked XenForo - I refused to use anything other than vBulletin until an hour or so ago ;-)

I have now decided, after looking over this forum for a while, that I like XenForo.

Just a quick question though, how are mods made? In VB 4, they are just php code run at hooks at places in the code. This was really easy. vB5 looks more like the WHMCS system, which I find complex and confusing.

So what is the XenForo system?

Also, I was in doubt as to where to post this so I posted it in off topic (if in doubt, it's off topic ;)).

Liam
Read through the Have You Seen...? section of the Official Forums to answer this question in detail.

Modifications here are made by extending XenForo code, to put it in simple terms.

Here are some links:
http://xenforo.com/community/threads/creating-a-simple-modification.3532/
http://xenforo.com/community/threads/how-to-use-template-hooks.13167/ (deprecated as of here)
http://xenforo.com/community/threads/how-to-add-more-actions-to-an-existing-controller.11202/
http://xenforo.com/community/threads/scratchpad-demonstration-ajax-add-on.8369/
http://xenforo.com/community/threads/xenforo-ajax-tutorial.8091/
 
(Was looking for the quote button then)

Well, I was going to say that first impressions weren't good, however the subscription email didn't contain your edit obviously, which made it much better ;-)

(Before the edit, you came across as unfriendly. It's a amazing what a smiley can do ;))

I actually thought that myself after I read it back and made the edit. But of course that wasn't the intention but I can see how you would think that as I thought it myself after reading it back. :)
 
Liam,

Check this tutorial by Lawrence to use as a starting point. :)

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

Nice guide that, although it does look like XenForo mods are complicated :-(


Nice link bunch there, but you're up a bit late aren't you ;-)
 
It's only 12:35am! Early...

Early bird catches the worm or whatever...

(You could also have noted the fact that I'm in the same time zone as you... :p)

I actually thought that myself after I read it back and made the edit. But of course that wasn't the intention but I can see how you would think that as I thought it myself after reading it back. :)

Few, thought it was just me, like usual :) I'm really starting to like this community!

Edit: Aw, Shelly I can't see your profile :-(

Also, when was this thread moved and by who...
 
It's worth noting that XenForo's code is MVC, so it's slightly more complicated at a glance. But once you learn how MVC works - and there are excellent tutorials here to teach you the basics of creating a good add-on - the code is very very clean, well documented (either in the code itself, or you can point PHPDoc at it), and very easy to work with.

As an example: My PHP experience before starting to work on XenForo add-ons was virtually nil. I'd picked up the absolute basics of crappy procedural code, knocked lumps out of a few free (also crappy) forum packages for fun, and then never did anything with that knowledge for several years.

Now, I am currently about half-way through creating an entirely custom feature (an integrated writing and art gallery), have made quite a few small mods for various things, and have lofty plans for a lot more. This is from following some tutorials here, then learning from the XenForo code itself as to the best way to do things. So although it's not immediately obvious as to how to do things, it's very easy to pick up and work with.
 
It's worth noting that XenForo's code is MVC, so it's slightly more complicated at a glance. But once you learn how MVC works - and there are excellent tutorials here to teach you the basics of creating a good add-on - the code is very very clean, well documented (either in the code itself, or you can point PHPDoc at it), and very easy to work with.

As an example: My PHP experience before starting to work on XenForo add-ons was virtually nil. I'd picked up the absolute basics of crappy procedural code, knocked lumps out of a few free (also crappy) forum packages for fun, and then never did anything with that knowledge for several years.

Now, I am currently about half-way through creating an entirely custom feature (an integrated writing and art gallery), have made quite a few small mods for various things, and have lofty plans for a lot more. This is from following some tutorials here, then learning from the XenForo code itself as to the best way to do things. So although it's not immediately obvious as to how to do things, it's very easy to pick up and work with.

Hmm, googling MVC now.

Googled, reading a site about it.

Doesn't look too bad, but I haven't been past page one yet...
 
Hmm, googling MVC now.

Googled, reading a site about it.

Doesn't look too bad, but I haven't been past page one yet...
Instead of learning about MVC in a general sense, I'd recommend just looking at existing free add-ons here and trying to understand the basics of how they work.

MVC sounds complex, but it makes sense when you look at the code if you have some basic PHP knowledge.
 
Instead of learning about MVC in a general sense, I'd recommend just looking at existing free add-ons here and trying to understand the basics of how they work.

MVC sounds complex, but it makes sense when you look at the code if you have some basic PHP knowledge.

Will do that, thanks.

Just need an XF license however, maybe I should sell my vB...
 
Hmm, googling MVC now.

Googled, reading a site about it.

Doesn't look too bad, but I haven't been past page one yet...
The short answer is: MVC stands for Model, View, Controller.

The idea is to separate your code so each function is only doing one job and doing it well. This means that other code can hook into it without any troubles.

Models are the modules that deal with reading data. For instance:
PHP:
    public function countWorksByUser($userId)
    {
        return $this->_getDb()->fetchOne('
            SELECT COUNT(*) AS total
            FROM cc_work AS `work`
            WHERE `work`.user_id = '.$this->_getDb()->quote($userId).'
        ');
    }
This bit of code counts the number of entries a user has in my custom tables. This is useful because several different things might want to count the works a user has - the cron job for awarding trophies, a permission system (for if I want to limit the number of works a user can create), and so on and so forth. I can just point them all at this code and have a single point of failure.

Controllers are the engines of your code - they actually do things. For instance, controllers are in charge of receiving the data from the models and working them into a form that can be used by a View. One of my simplest controllers is:
PHP:
    public function actionNew()
    {
        $this->assertCanDo('canCreateWork');
       
        return $this->responseView('CreativeCorner_ViewPublic_New', 'works_new');
    }
This is called by XenForo's routing system (which is a topic outside the scope of this post), and simply calls my function for checking user permissions, and then responding with a View.

Views are in charge of turning the data the controller has worked with and presenting it - whether that be to the user, or as a JSON request, or otherwise. The nice thing about XenForo views is that a lot of the time they don't need to actually exist - CreativeCorner_ViewPublic_New does not resolve to a real View, as XenForo takes care of that for me. Although you don't need to actually do this yourself, most Views take the data and tell XenForo to output a template.

There are also DataWriters, which basically tell XenForo about the database and your tables - and of course are used in extending XenForo's methods that write to the database.

This isn't designed to be an tutorial or anything, just an illustration of the basic elements. I strongly recommend you follow through some of the Development Tutorials, which do a far better job of explaining things than I do :D
 
The short answer is: MVC stands for Model, View, Controller.

The idea is to separate your code so each function is only doing one job and doing it well. This means that other code can hook into it without any troubles.

Models are the modules that deal with reading data. For instance:
PHP:
    public function countWorksByUser($userId)
    {
        return $this->_getDb()->fetchOne('
            SELECT COUNT(*) AS total
            FROM cc_work AS `work`
            WHERE `work`.user_id = '.$this->_getDb()->quote($userId).'
        ');
    }
This bit of code counts the number of entries a user has in my custom tables. This is useful because several different things might want to count the works a user has - the cron job for awarding trophies, a permission system (for if I want to limit the number of works a user can create), and so on and so forth. I can just point them all at this code and have a single point of failure.

Controllers are the engines of your code - they actually do things. For instance, controllers are in charge of receiving the data from the models and working them into a form that can be used by a View. One of my simplest controllers is:
PHP:
    public function actionNew()
    {
        $this->assertCanDo('canCreateWork');
     
        return $this->responseView('CreativeCorner_ViewPublic_New', 'works_new');
    }
This is called by XenForo's routing system (which is a topic outside the scope of this post), and simply calls my function for checking user permissions, and then responding with a View.

Views are in charge of turning the data the controller has worked with and presenting it - whether that be to the user, or as a JSON request, or otherwise. The nice thing about XenForo views is that a lot of the time they don't need to actually exist - CreativeCorner_ViewPublic_New does not resolve to a real View, as XenForo takes care of that for me. Although you don't need to actually do this yourself, most Views take the data and tell XenForo to output a template.

There are also DataWriters, which basically tell XenForo about the database and your tables - and of course are used in extending XenForo's methods that write to the database.

This isn't designed to be an tutorial or anything, just an illustration of the basic elements. I strongly recommend you follow through some of the Development Tutorials, which do a far better job of explaining things than I do :D

Very nice post, that actually made me understand - thanks!
 
Back
Top Bottom