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

Fixed  2 bugs in XenForo_Link (Link Generation)

Shadab

Well-known member
#1
(1) Lines 272 - 275
PHP:
		if ($prefix === 'index' && $action === '' && $extension === '')
		{
			return '';
		}
Please consider removing this check, as it interferes with the link generation for "index" route prefix. This doesn't pose any problem in a stock xenforo instance; but it prevents us from utilizing the buildLink() method for building index links via the prefix handler.

Removing this condition shouldn't break anything else because XenForo_Link::buildBasicLink(), which is used as a fallback method, contains a similar check.

(2) Lines 370 - 377
PHP:
		$class = $info['route_class'];

		if (!XenForo_Application::autoload($class))
		{
			return false;
		}

		$handler = new $class();
The route class is instantiated directly here, instead of passing it through resolveDynamicClass() first. So any extended route prefix class doesn't get hooked; which makes it impossible to override the buildLink() method for any route prefix.
 

Mike

XenForo developer
Staff member
#2
I've made the change for #1, though unless you're changing when the route class is loaded for link building, I'm not sure if it's going to really help much.

The #2 change is useful though.
 

Shadab

Well-known member
#3
Thanks! :)

And yes, the #1 change was kind of needed to effectively swap the index route prefix with some other route prefix. Makes it very easy to use my own prefix/controller combination for the homepage.
 

skhms

Active member
#4
Would also love to see the #2 thing changed.
Just ran into that problem. Must say that I got a bit disapointed when it didn't work to override the buildLink() method.

/SK