Sam Dorman of the League of Young Voters just tickled my funnybone with a really nice idea for how to elegantly handle external redirects in Plone. I think this would be really easy to roll up into a nice user-friendly product that would have tremendous, wide-ranging re-usability. I’d love your thoughts on it.
The problem
Lots of online activism campaigns (like the League!) use generic content management tools like Plone for their main website and supplement it with more specialized online advocacy tools like Democracy In Action. It’s a winning combination that takes advantage of inexpensive, easy to use, best-of-breed tools.
The problem is that you can wind up with some messy URLs. For example, Democracy In Action URLs can look like this:
https://salsa.democracyinaction.org/o/315/my/donate.jsp?supporter_my_donate_page_KEY=someVariable
Ugh. Not very user friendly to stick into an email, a tweet or a blog post. What Sam really wants is to have a redirect URL like this:
http://go.theleague.com/someAction/someVariable
That will automatically redirect you to the DIA page, with someVariable appended.
“Why not just do this with Apache rewrite rules?” I can hear you asking. Because Sam’s not an apache administrator, and doesn’t know how to write a regular expression (and neither do I). We want these to be manageable by people with Plone-user skills, not server-admin skills!
My vision
As Sam was telling me his story, a little vision appeared in my mind’s eye.
I imagine an “external redirects” control panel in Plone, where you would be find a screen that would let you add lightweight “redirects” that would have the following attributes:
- Redirect name (the “someAction” in the example above)
- Redirect destination (the external URL you’re redirecting to. Variables to be allowed with things like $1, $2)
- Enabled/disabled checkbox
I’d see this as a DataGridWidget or something similarly quick and easy. A site could have quite a few redirects to manage on a single screen, we’d need to use KSS well to avoid too many page reloads.
Practicalities
Plone’s current “Link” object supports some very basic external redirection, and we could extend that as described at PLIP 126, but I’m not convinced that this is a very ideal approach. The use case I’m trying to cover is about “placeless” adminstration of lots of links, not administering one-by-one links that are scattered within the content hierarchy. Also, implementing this functionality with full-fledged content objects creates some problems with viewing vs. editing mode, which I think can be avoided with a centralized, approach based on a utility tha could be overriden or extended.
The other concern that would have to be addressed with this approach is namespace collision. I think that could be avoided by doing a quick catalog search to make sure your proposed actionName doesn’t conflict with an existing content object (KSS validators to the rescue!). We might be able to entirely avoid namespace collision by letting you define a subdomain in the control panel (e.g. go.mydomain.org), and if possible push that into VHM.
We’d probably need to sanitize variables so that this doesn’t allow any weird injection attacks.
I’m not convinced. Having placeful link objects with the improvement proposed in PLIP 126 is the easiest way to implement this without having to create new infrastructure (e.g. some skin-layer-esque abuse of the traversal machinery). And it has the advantage of making the namespace issue go away because you can’t create link objects with the same id as another object.
Certainly we could add a centralized control panel to view and manage the links in a site, though. Then you could get a placeful or placeless view as desired.
Yes, maybe there’s a “both/and” approach. I’m most interested in making it easy to do simple variableization and, if possible, to have a dedicated subdomain.
I like it. I’ve often thought, it wouldn’t be very hard to setup something like tinyurl to run on your own web server. In Plone, there could be a “make custom link” item in the site setup control panel. The interface could be as simple as tinyurl’s front page (with the new alias feature). Just type a full url into a text box, type the alias into a second text box and hit “make it”. There would be one other button/link on the page: “administer custom links” (or whatever) that would display a grid with checkboxes and a “delete selected” button at the bottom.
Another thought: how about a variation of the link content type where the default view is a redirect? You could just put the “external alias link” wherever it belongs in the hierarchy of the site and when a visitor comes to that location, they’re immediately redirected to the external url.
Hi! I know I’m a little late into the discussion! I too am looking for solutions to let a user define a custom link, as Joel says and just found Redirector:http://plone.org/products/redirectiontool.
Doesn’t says anything about query string variables but at least it lets a user define multiple redirection links and thus aliases. In theory you can define http://somesite/a/long-descent/into/the-bowells-of said-site/prized-link to http://somesite/here-I-am .
Currently we have Plone 2.5.2 deployed and this product is compatible with both 2.1 and 3.0 so I hope it is compatible with 2.5.2 also. I’ll will test it and let you know as soon as I can.
Hello Again! I tried version 1.2.1 on Plone 2.5.2 and it crashes the site! Documentation does not says to work exclusively with version 3.0 but guess I answered that one the hard way. I then tried version 1.1 since it works on Plone 2.1 it “should work” in 2.5.2 . It doesn’t no crash the site on installation but redirection simply does not work. I’ll try to have another test environment with Plone 3.0 and see what I can get.
@ILVC, I’m sorry this isn’t a good support forum for Redirection Tool; please see the plone-users list (http://plone.org/support/forums/general)