How do I force full URLs?

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.
 
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!
 
Oh yes I do. ;) I like that atmosphere. It was a fun read to read both the controller and about 4 other XF files... :D
 
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'));
 
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!
 
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?
 
Why would you ever NOT want to use full links? Full links would get sorted in search engines better, wouldn't they?
They shouldn't make a difference for SEs. Very few links in XF are "full" links.
 
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.
 
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.
 
Top Bottom