I love the module.

I implemented the patch from Cloudy in the ability to use variables in path feature request. After doing so, I noticed that the module does not parse the specified paths to a base url and parameters. This causes issues with the drupal_goto command and the default response of a "302 Redirect". The parameters are parsed as part of the base url which causes them to be url encoded and not function properly as parameters.

I am using this module in conjunction with the prepopulate module which allows form fields to be pre-entered by passing parameters in the URL. This is obviously not working.

Sample expected/desired URL:

http://samplesite/node/add/content_ccktype?edit[TITLE]=new&edit[taxonomy][2]=31

Actual Generated URL

http://samplesite/node/add/content_ccktype%3Fedit%5BTITLE%5D%3Dnew%26edit%5Btaxonomy%5D%5B2%5D%3D31

I was able to change the behavior of the module with a few small changes (Changes are placed on top of the patch from Cloudy listed above):

function nodegoto_nodeapi(&$node, $op, $teaser = NULL, $page = NULL) {

    $nodetype=$node->type;
    $nid=$node->nid;
    $nodeto = module_exists('token') ? token_replace(variable_get('nodegoto_'.$op.'_'.$nodetype,''), 'node', $node) : variable_get('nodegoto_'.$op.'_'.$nodetype,'');
# Parse the supplied url into a base and parameters
    list($nodeto, $parms) = explode( "?", $nodeto);

    if (variable_get('nodegoto_camefrom',0)==1){
  $camefrom='camefrom='.urlencode('node/'.$nid);
     if ( $op == 'insert' && $nodeto!=''){
        drupal_goto($nodeto,$camefrom);
           }
     if ( $op == 'update' && $nodeto!=''){
        drupal_goto($nodeto,$camefrom);
           }
     if ( $op == 'delete' && $nodeto!=''){
        drupal_goto($nodeto);
           } }
  else{
  if ( $op == 'insert' && $nodeto!=''){
        drupal_goto($nodeto, $parms);
           }
     if ( $op == 'update' && $nodeto!=''){
        drupal_goto($nodeto, $parms);
           }
     if ( $op == 'delete' && $nodeto!=''){
        drupal_goto($nodeto, $parms);
           }
  }


}

I added the "list(..." line, then added the $parms variable as a 2nd parameter in the calls to goto_drupal after the else.

I did not make any changes to the "camefrom" section of the code because I am not using that on my site, and do not have an easy way to set it up.

I am including a patch, but I have never created a patch file before, so I am not sure if this will work for anyone. I renamed the original file to nodegoto.patched_token, then created the diff.

I just want to share my hours of debugging in the hope that someone else can benefit from this.

CommentFileSizeAuthor
nodegoto_parms.patch1.39 KBbighoffa

Comments

introfini’s picture

Hi bighoffa,

I’m sorry to taking so long to answer.

Can you please test the new version?

Thanks,
introfini