Project:CCK Redirection
Version:6.x-1.2
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:needs work

Issue Summary

It''d be useful to be able to redirect to a url with a fragment/query.

So far to get it working I changed

<?php
            $url
= parse_url($element['#item']['value']);
           
drupal_set_message(t('This node is redirected to a !r.', array('!r' => l(t('remote URI'), $url['path'],
                array(
'query'=>$url['query'],'fragment'=>$url['fragment'])
                ))));
?>

<?php
function _cck_redirection_divert($element) {
  if (!empty(
$element['#item']['value'])) {
    
$url = parse_url($element['#item']['value']);
   
drupal_goto($url['path'],$url['query'],$url['fragment']);
  }
}
?>

Reading the other issues I understand this module has issues with line endings so didn't make a patch (or rather... lazy fox, lazy).

Not sure how'd this effect remote urls, only tested for insite urls and it worked fine for both the message and the redirect.

Comments

#1

It appears that the line ending problem referenced as a reason not to create a patch is still open over a year later. Mostly as a quick reference for myself, I've converted his edits to a patch.

AttachmentSize
593376.patch 1 KB

#2

Status:active» needs work

This patch has been tested and breaks cck_redirection fields that reference external sites. If you can correct this patch to work correctly both on internal and external URLs I'll work to get it committed.

#3

Status:needs work» needs review

I created a quick helper function that takes the URL apart with parse_url and then logically puts it back to together. Nothing too fancy, but it seems to be working for internal and external sites, as well as with queries and fragments. I did build in port, user, and password support, which I'd be surprised if anybody used, but you never know.

I made the patch based on 6.x-1.2; it also includes the (now all re-written) work from hefox's patch. I also deleted any Windows newlines in this patch file (I just saw that they were removed in dev, awesome!). I hope that doesn't hamper any progress in getting this committed.

AttachmentSize
593376-2.patch 2.64 KB

#4

Status:needs review» needs work

In light of http://drupal.org/node/445894 this patch seems to duplicate some of the URL validation accomplished there; I'd prefer if we could reuse most of that logic.

/Robin