I could not figure out how to create Url Alias to change exposed filter url from e.g. www.example.com/viewabc?tid=11 to www.example.com/viewabc/xyz where xyz is 11th taxonomy term.
How can I get rid of "?".
Sorry if this is too trivial question, I couldn't find a solution.
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | path.admin_.inc_.diff | 545 bytes | gravisrs |
Comments
Comment #1
merlinofchaos commentedURL aliases don't support query arguments; at the moment there is no way to do this. Someone expert might be able to figure out a way to do it with argument defaults and stuff, but for now exposed filters simply can't do what you want.
Comment #2
sbydrupal commentedThanks Merlin for quick reply.
Is this a solution for exposed filter Alias from previous posting "http://drupal.org/node/118072" with title "
"?" not supported in a path alias?"
================================================
imrook - March 23, 2008 - 00:28
I have recently run into this problem and have a solution that meets my needs so I'll chime in with my two cents here. The part after the '?' character in the URL is called the query string. boombatower created an issue with a patch for this problem here. Some users complained that it didn't work -- I personally haven't tested it. chx doesn't seem too intent on adding the functionality at this time.
But there is still hope. Here's why the problem occurs in the first place: Apache uses mod rewrite to rewrite a URL like http://mysite.com/drupal/admin/build/menu to become http://mysite.com/drupal/index.php?q=admin/build/menu. During the bootstrap phase, Drupal uses the value of the variable $_GET['q'] to map a URL to a function call. Now look what happens with the following URL: http://mysite.com/drupal/path_alias?myvar=1 Apache's mod_rewrite turns it into http://mysite.com/drupal/index.php?q=path_alias&myvar=1 This is normally a good thing. The problem with Drupal is that the core doesn't look at any other variables besides $_GET['q'] so it will only use path_alias for the lookup. Luckily Drupal provides a place where we can change that: custom_url_rewrite() Add the following code to your settings.php file:
}
This will allow you to set a path alias for a node that contains a query string and Drupal will redirect to the correct page. Note that when Drupal generates a link to the node it will be urlencoded, but it will still work properly.
This code is actually written for 5.x In Drupal 6, the function is called custom_url_rewrite_inbound and the parameters have changed a bit. I haven't taken a look at 7 yet so I don't know anything about that.
==================================
Comment #3
j0k3z commentedDid anyone figure out the Drupal 6 code?
Comment #4
heyyo commentedAny update on this issue ?
Comment #5
heyyo commentedComment #6
dawehnerSee above #2
Comment #7
gravisrs commentedFor those who couldn't find how to make it in Drupal 6:
Sorry for bit dirty code. There should be few more checks/ifs to make it bulletproof but the main idea is included.
Now, to make it possible to add aliases with additional query parameters in admin/build/path/add we could use attached core hack to bypass form validation. [Or write a module to hook validation and bypass it in 'proper' way].
Comment #8
alladdin commentedThe code in #7 is not working on drupal 6.2 with views 3.
admin/build/path is not accessible with 404 error.
Can someone please finalize this code.
Comment #9
marko b commentedI am also very interested in this. Why is this any different (views) than normal url rewrite? they are just parametars sent with get method, right? I must be missing something in complexity...
Comment #10
brian_c commentedI have this working for D7 (and Views 3) via hook_url_inbound_alter(): http://drupal.org/node/118072#comment-4706374
Comment #11
killah89 commentedIm very interested too in this code for D6. Please fix it and make it work. I cannot use query strings in url aliases. When i have a "?" in the url, the site gives an apache error. And when i have a "=" in my path, its not show correctly. Please, please make it work for D6.
Tanks a lot.