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

How do I force full URLs?

Jaxel

Well-known member
#2
Figured it out:
Code:
$this->canonicalizeRequestUrl(XenForo_Link::buildPublicLink('media', $media));
Some warnings though... normally you want to use 'full:media' instead of just 'media' when building public links. This way it generates a full absolute URL, instead of just a relative URL. However, when you try to use 'full:' while building a canonical URL through XenForo's system, it creates a redirect loop.

You can also add ", array('page' => $page)" to the end of your buildPublicLink functions. Supposedly this includes query information into the canonical URL. However, I have removed this section and it still maintains the page query... so I dont think it's needed.
 

Jeremy

Well-known member
#3
Try:
PHP:
$this->canonicalizeRequestUrl(XenForo_Link::buildPublicLink('media', $media, array()))
I haven't looked at any of your code for proper buildPublicLink() setup, but I think this will work. Only thing I could think of.

Edit: I see you were working just as hard as I was!
 

Shadab

Well-known member
#6
When in a controller, you can also build links using the _buildLink() method.
This was introduced in Beta 4.

PHP:
$this->canonicalizeRequestUrl($this->_buildLink('hello'));
 

Mike

XenForo developer
Staff member
#7
Some warnings though... normally you want to use 'full:media' instead of just 'media' when building public links. This way it generates a full absolute URL, instead of just a relative URL. However, when you try to use 'full:' while building a canonical URL through XenForo's system, it creates a redirect loop..
I'm curious as to why you'd normally want "full"? It's primarily used in breadcrumbs for metadata reasons, and occasionally it's used where there are base tag issues. Normally, almost all of your links would be relative. ("Canonical" is a different type of link, though it's probably not applicable here - if anything, it'd be applicable everywhere.)

When in a controller, you can also build links using the _buildLink() method.
This was introduced in Beta 4.

PHP:
$this->canonicalizeRequestUrl($this->_buildLink('hello'));
True, though the only reason that function appeared was for canonicalizePageNumber()... and, err, it's not even using it? Oops!
 

Jaxel

Well-known member
#8
I'm curious as to why you'd normally want "full"? It's primarily used in breadcrumbs for metadata reasons, and occasionally it's used where there are base tag issues. Normally, almost all of your links would be relative. ("Canonical" is a different type of link, though it's probably not applicable here - if anything, it'd be applicable everywhere.)
Why would you ever NOT want to use full links? Full links would get sorted in search engines better, wouldn't they?
 

Jaxel

Well-known member
#10
They shouldn't make a difference for SEs. Very few links in XF are "full" links.
Hmm... then is there a realistic reason of why you wouldn't want to use full links?

I can easily remove the "full:" references in my mods... I just want to know if there is a good reason to do so.
 

Mike

XenForo developer
Staff member
#11
I could just as easily ask the opposite question. :)

They really provide no benefit in the average case - thought there are some edge cases where you need them. But on the whole, they're just redoing the work of the base tag. If anything, it's just unnecessary characters.