• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Use class to build link - What's going on?


Well-known member
I'm trying to build admin navigation link for my addon, and having hard time figuring out what's really does these options signify:-

Use class to build link: Always | Only when data is provided | Never.

I see that some of the options have 'Never' while others have 'Only when data is provided'.


1. Which 'class' is this option talking about?
2. What decides 'Always' , 'Only when...' and 'Never'?

Thank you for reading and I'd really appreciate every response.

Liam W

Well-known member
That is when you add a new route to the system.

A route is, for example, forums/, members/, threads/ etc.

Admin routes are what comes after the question mark: ?users/, ?forums/ etc.

When adding a new route, you need to give the system a route class, that implements the XenForo_Route_Interface (it should also, technically, implement XenForo_Route_BuilderInterface but I rarely see route classes that do).

Use class to build link controls when the methods inside aforementioned class are called. Always means the methods are called every time a link with the route is created.

Only when data is provided means that the method to build the link is called only when data is passed to the link builder method.

Never means the class is never used to build the link, as in it doesn't contain the buildLink method.

If you just want to create an admin navigation entry for an existing route/action (such as with an extended controller), go to admin.php?admin-navigation/ and create a new entry - you enter the link that the user is taken to, such as misc/update-xenforo in my add-on :)



Well-known member
Thanks a lot, @Liam W . That surely helped! I'm assuming that for every Admin Navigation, we'll have to associate a route prefix. I've created an Admin Navigation with:

Admin Navigation ID: MyAddons
Title: My Addons
link: myaddons <- I guess I need to set this up.
Display order: 2000
Add-on: XenForo

Now I do get a Tab after 'Development' but clicking on it shows a message "Route myaddons/ could not be found."

I think I will have to create an Admin Route that implements XenForo_Route_Interface.

Q1. Is that a correct approach?

Also, I'd like to have this 'My Addons' tab to have options for all my future addons like:-

Addon - I

Addon - II

I've seen some of the options in XF AdminCP, viz. Users->Contact Users-> Alert Users have a link: admin.php?users/alert .

Q2. Now I'm wondering how do I build a link like that using Route Prefix?