I got excited a while back about the idea of using weblink resources to manage external links on our site. Broken links to external sites would be a lot easier to manage this way - I could have an "external links" branch in my resource tree, organized by site.
The only problem is that for an external link, I don’t want the normal weblink functionality of the link tag outputting a local/MODx friendly URL - I want the actual external URL to be displayed. In other words, if I have a branch of weblink resources that looks like this:
externallinks/ (28)
-othersite1/ (29) (http://www.othersite1.com)
If I use the link tag [[~29]], I want it to output "
http://www.othersite1.com" - not "externallinks/othersite1/".
I know that either version will *take* me to the same final destination, but for external links the link really needs to be external from the start.
I’ve thought of a few ways I could output the direct URL - I could use getResources, for example, instead of a link tag. But I really want to be able to work with these weblinks in the normal way - to drag/drop them from the resource tree, look them up with the TinyMCE link search, etc.
My best idea so far is this:
- Create an "external link" template to use on weblinks to external URLs (just as a way of flagging them as external)
- Create a snippet that outputs the direct URL of a weblink resource (to be used as an output filter on the link tag)
- Create an OnBefore[Doc|Chunk]FormSave plugin that inspects the link tags in the resource/chunk, checks to see if they are weblinks that use the "external link" template, and if so adds the output filter
So now, my standard questions:
- is this insane?
- is there a more sane way to accomplish this?
And also:
- Would this be a good candidate for a feature request?
I feel like it would (be a good candidate for a feature request). I’m just not sure how it would best be implemented. Could be a checkbox on the weblink resource form (if checked, link tags should output the direct URL). Or could be a new modifier on the link tag itself. I’m curious what other people think about this.