New Route Controller for xenforo 1.4.3

Hi Guys,

I am a Software Developer from Germany. My Company is currently working with vBulletin Forums. In this year we want to change to xenForo. I wrote many Addons for vBulletin but I am a beginner in xenForo.
I have seen a few Video Tutorials about how to make a Addon in xenForo. It seems reasonable.
Now I have to write a new route controller.
Can somebody explain the first steps to me. What do I have to make to replace the current route controller with a new one?
I hope for your help.




Well-known member
@Mailman32 Do you want to create a new route, or replace an existing XenForo route? By reading your post it sounds like you want to replace an existing XF route with one of your own. Also, is the route for the admin side, or the public side?


Well-known member
Unless you are going to add some other functionality to the route, your above example can be accomplished with a route filter:
AdminCP -> Route Filters -> Create Route Filter

Find Route: threads/
Replace with: forum/

and then Save Route Filter


Well-known member
Sorry, :) You want the forum name and sub-forum name in the in the url?

If you look at XenForo_Route_Prefix_Forums you will see that node name and title may be contained in $data, so you can start there. To extend or replace that class with your own custom class use an event listener to listen for load_class_route_prefix and in the hint field put in: XenForo_Route_Prefix_Forums. It's a start, :)
Thank you very much for your help. These are definitely very useful tips. I will try to implement that.
I will contact you as soon as I have something new :)
Hi there, same company as Mailman32 here. ;)

Just to elaborate and clarify:

Currently 'categories', 'threads' and 'forums' are three separate route prefixes in the default xenForo setup.

The way we want to build urls is this:

Category: {root}/forum/[{parent-category-or-forum-slug}/]*{category-slug}
Forum: {root}/forum/[{parent-category-or-forum-slug}/]*{forum-slug}
Thread: {root}/forum/[{parent-category-or-forum-slug}/]*{thread-slug}.{thread-id}
So, basically, we want to unify those three route prefixes into one that does branch it's logic depending on what content is refered.

We could just remove the core prefixes, add our own, and overwrite the public controllers to change
    XenForo_Link::buildPublicLink('threads', $thread, array('page' => $page))
to something like this (roughly)
    XenForo_Link::buildPublicLink('forum', $thread, array('page' => $page))
But this would require us to overwrite methods like 'XenForo_ControllerPublic_Thread::actionIndex', which we would rather avoid.

So the question would be: Is there a more elegant, non-invasive, way of achieving this? :)