How do I use a URL w/special characters?

cultiv8 - March 27, 2009 - 20:34
Project:Jump
Version:5.x-1.1
Component:Code
Category:support request
Priority:normal
Assigned:Unassigned
Status:active
Description

Hi, how do I use a URL with special characters? If I use "&" or "?" in the URL, Drupal encodes it into plain text, and then the page I jump_quickly to has an incorrect URL. For example:

<?php
 
global $user;
 
$options = array(
     
'products/56?v1=AND&v2=6' => t('Link Title')
  );
  print
jump_quickly($options);
?>

sends the user to www.example.com/products/56%3Fv1%3DAND%2526v2%3D6 but I really want it to point to www.example.com/products/56?v1=AND&v2=6. Any help would be appreciated.

#1

cultiv8 - March 29, 2009 - 16:25

As a follow up, I ended up hard-coding the URL into the array and it works the way I want it to. I know hard-coding isn't best practices, but hey, it works. So to anyone facing the same problem, this is how your code should look if you want special characters in your path:

<?php
 
global $user;
 
$options = array(
     
'http://example.com/products/56?v1=AND&v2=6' => t('Link Title')
  );
  print
jump_quickly($options);
?>

#2

kmiles - August 11, 2009 - 04:16

Thanks cultiv8, this info concerning the url encoding was quite helpful.

 
 

Drupal is a registered trademark of Dries Buytaert.