When [[~23]] link tags get parsed, they call modX::makeUrl with the default scheme of ’-1’ (URL is relative to site_url).
This is *why* MODx requires <base href="[[++site_url]]" /> (is it not?)
When modX::makeUrl is called with the scheme of ’abs’ (URL is absolute, prepended with base_url from config), the result is a "root relative" URL. My base_url is ’/’ (MODx is installed at site root) - so if I have resource 23 with an alias of foo/bar.htm...
[[~23?&scheme=`abs`]] results in /foo/bar.htm.
So...
if I could change the default scheme from ’-1’ to ’abs’... all my links would be root-relative... and (wait for it)... I would no longer need to use the <base href=[[++site_url]]> trick.
Right?
Right?
The base href requirement (and the subsequent ’anchors workaround’ requirement -
http://www.modxperience.com/modxperi/experience/quick-tips/fake-anchors.html?quip_approved=0#quip-success-qcom) has been bugging the crap out of me lately, because it seems to be a nagging, annoying exception to the otherwise truthful & awesome claim that "MODx doesn’t dictate anything whatsoever about how you choose to write your HTML". Its the type of thing where, if I weren’t already sold on MODx and were evaluating it as a potential tool, I could easily see myself thinking "that’s lame" and moving on to the next CMS.
Am I missing something?
Are there downsides to a root-relative URL strategy? Downsides that would outweigh the benefit of being able to ditch "base href" and have proper anchor behavior without a workaround?
I’m submitting a feature request to add a system setting that dictates the default URL scheme used when parsing link tags. I think it would be nice to at least have this option.