This is really basic and stupid, and I have searched the site for an answer but can't find one.
I'm just trying to create a menu item:
Home › Administer › Site building › Menus
The form prompts for Title, Description, Path, Parent item, etc.
In the path I want to specify a URL that has query arguments:
view/ticketselector?sort=asc&order=Priority&op0=OR&op1=OR&filter1[0]=6&filter1[1]=7&op2=AND&op3=OR
It is a custom view of my cases from casetracker. Well the URL gets encoded so it doesn't work:
view/ticketselector%3Fsort%3Dasc%2526order%3DPriority%2526op0%3DOR%2526op1%3DOR%2526filter1%5B0%5D%3D6%2526filter1%5B1%5D%3D7%2526op2%3DAND%2526op3%3DOR
How do I tell drupal to not url encode the thing? This seems like a basic thing to want to do. . .
Thanks,
-Bob
Comments
No help available?
Anyone?
I got it working by...
commenting out a line in common.inc (line with XX in)
although I'm not sure of the side-effects of this. I guess it should be done properly with the $query variable but I can't get my head round it just now.
I want to get it working because I want a link that logs a user in and goes to a particular page (I know there is a module for this...) and I want a primary link like "Log On To Members' Area" with a url like user/login?destination=members, which does this nicely
Set your 404 page to a node
Set your 404 page to a node that you create in php format. I use an include file from disk to set up a notification system which sends me an email for any site called resource (meaning, if it comes from outside the site, I don't care about it). To account for the fact that I want to catch url arguments correctly, I use the following code:
This only covers the characters =, ? and &. I haven't had need for any others, but it works.
you can do it by inserting
you can do it by inserting the following function to your templates.php file in the your theme directory:
function phptemplate_menu_item_link($item, $link_item) {
$url = parse_url($link_item['path']);
// if our path has a query , move this query from $link_item['path'] to $item['query'], so l() function can append it properly
if (isset($url['query'])) {
$link_item['path'] = str_replace('?' . $url['query'], '', $link_item['path']);
$item['query'] = $url['query'];
}
return l($item['title'], $link_item['path'], !empty($item['description']) ? array('title' => $item['description']) : array(), isset($item['query']) ? $item['query'] : NULL);
}
this will correctly display query arguments for every menu item, but keep in mind that parse_url is performed on each menu item, and it can be very expensive, so consider to place some condition matching your case, something like:
function phptemplate_menu_item_link($item, $link_item) {
if (strstr($link_item['path'], 'view/ticketselector?')) {
$url = parse_url($link_item['path']);
if (isset($url['query'])) {
$link_item['path'] = str_replace('?' . $url['query'], '', $link_item['path']);
$item['query'] = $url['query'];
}
}
return l($item['title'], $link_item['path'], !empty($item['description']) ? array('title' => $item['description']) : array(), isset($item['query']) ? $item['query'] : NULL);
}
hope, it helped
Perhaps a cleaner way?
I think it might be a bit easier to do it like this-
For non-encoded links
The above code handles encoded links, this handles non-encoded (eg: path/mine?argument=blah)