Environment
mysql Ver 14.14 Distrib 5.1.22-rc, for redhat-linux-gnu (x86_64) using readline 5.0
Drupal 5.6 - pretty much just core, added modules IMCE, Tinymce

I'm creating menus and I put the link for a menu item as:

forecast/products?fcast=coos1

When I rollover the menu item in Firefox I get the link (along with the added http://myhost.org/) as displayed above in the FF status bar but when I click on the link, Drupal converts the ? and = and a page not found error is displayed. The link winds up being:

http://myhost.org/forecast/products%3Ffcast%3Dcoos1

I must be missing something important about menu items here as I think there should be no conversion.

Thx,

--pturner

Comments

mdixoncm’s picture

Ahh - yes at the moment you can't have query strings or fragments in the URLs used in your menu items - which is a bit of a pain. I think there are a couple of patches kicking around (this one is for 6 though http://drupal.org/node/90570) so it might be worth having a bit of a google around.

The other option would be to pop something in the theme layer and override theme_menu_item_link and get it to parse the URL and extract any querystring or fragment args before passing into the l function ...

Mike,
Computerminds offer Drupal development, consulting and training

mdixoncm’s picture

I've just had a bit of a play and come up with the theme override -

function phptemplate_menu_item_link($item, $link_item) {

  if (!$item['query']){

    $parsed_url = parse_url($item['path']);

    if ($parsed_url['query']){

      $item['query']=$parsed_url['query'];

      $link_item['path']=$parsed_url['path'];

    }

  }

  return l($item['title'], $link_item['path'], !empty($item['description']) ? array('title' => $item['description']) : array(), isset($item['query']) ? $item['query'] : NULL);

}

if you pop that into your template.php file then you should hopefully find your links are working :)

Cheers,

Mike,
Computerminds offer Drupal development, consulting and training

pturner’s picture

Mike,

Thanks for your assistance and the pointers and the code, check's in the mail. The code didn't work for me right off but I'll investigate more. What is working is putting the complete url in the menu item - not the best solution but enough to get me going.

Thx,

--Paul

challa.kamal’s picture

i want same thing like this. Thanks for your answer

Kamal Challa

darkcss’s picture

This did work, thank you sir!