Navigation terms with spaces and & characters in kills site
budda - August 18, 2006 - 15:00
| Project: | Article |
| Version: | 4.7.x-1.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | critical |
| Assigned: | Unassigned |
| Status: | closed |
Jump to:
Description
If a user navigates to an article page for a term which has a space or an '&' character in it (example "Cars & Trucks"), the page goes blank.
A partial fix was achieved by adding $last_term = urldecode($last_term); in to the following function:
function article_build_breadcrumbs(&$breadcrumb) {
if (arg(1) != NULL) {
$i = 1;
$url = 'article';
$breadcrumb[] = l(drupal_ucfirst(variable_get('article_title', t('Article'))), $url);
while (arg($i) != NULL) {
$last_term = rawurldecode(_article_arg($i));
$url = $url . '/' . urlencode($last_term);
$breadcrumb[] = l(drupal_ucfirst($last_term), $url);
$i++;
}
$last_term = urldecode($last_term);
$term = current(module_invoke('taxonomy', 'get_term_by_name', $last_term));
return $term;
}
return NULL;
}This now, at least, lets me browse the category pages. However the term in the breadcrumb still has the encoded characters "Cars%20%26%20Trucks"
If a user then clicks on the breadacrumb link "Cars%20%26%20Trucks", article.module goes to a white page as it's trying to access ?q=article/Cars%252520%252526%252520Trucks - it's encoded itself again!

#1
Taxonomy terms with a / in them mess up to as it then divides up the path argument in to multiple bits.
So a term such as 'I/O & Expansion Cards' will not work with article.module
#2
This issue seems to appear with only spaces as well. So a taxonomy item of "My Stuff" blanks to a white page. There seems to be an issue with the spaces as I have a couple of taxonomy items with dashes which appear to work. Another side effect is the pager at the bottom blanks if a user moves to the next page.
What would be cool is if the article module followed the URL aliases created for the taxonomy items. How that would work, off the top of my head, is the challenge.
#3
#4
I can't reproduce this with the 5.x-1.0
Can you please test it ? or are you still using 4.7 ?
#5
I'm using this with Drupal 5.0 and still have the same issue.
I've tested Firefox, Safari and IE 7.
I'm running this on Mac OS X with Apache 2.
I will test Apache 1.3 at some point soon.
#6
Odd. I can't reproduce this.
What's your php version ?
What's the term that's causing the problems ?
What's the depth of the term ?
#7
I'm having the same problem in a location vocabulary that has a Category named "United States". If I click the breadcrumb for the category I get a blank page. I tried changing the name to "UnitedStates" with no space and it started working fine.
#8
Sorry for lack of follow-up. I was using Drupal 4.7 with the module, but had to stop using it as it didn't work. As such i've not got anything to test with now.
#9
Drupal 4.7.4, latest article.module
OK, I've used the 'fix' that started off this thread (i.e., $last_term = urldecode($last_term);) and that fixed the breadcrumbs thing.
But the 'next' 'previous' links still bring up a blank screen. Pretty much all my terms have spaces in them.
I noticed a curious thing this link brings up a blank screen:
http://www.zts.com/article/2.%2BThermoelectrics%2B-%2BCooling/Module%2BM...
but this one (with an extra '/' just before 'page=2') works as expected:
http://www.zts.com/article/2.%2BThermoelectrics%2B-%2BCooling/Module%2BM...
I'm looking for the code that does those navigation 'next' 'previous' links when there are more than one page of articles. I'm guessing that's part of drupal core? Certainly would hesitate to mess with that!
Soooo close ...!
- Cronin
#10
Seems that the idea of using the terms to generate the URLs is a bit problematic although I personally like it.
I'm currently rewriting the module to generate URLs using term IDs not the terms. This should produce URLs that are not as friendly as before but should solve all of the problems.
The code is in the DRUPAL-5--2 branch. I just don't have much time these days (job change + relocation)
I'll backport it to 4.7 when it's done (I'm still personally using drupal 4.7)
#11
Can you please test with 4.7.x-1.2 (http://drupal.org/node/124444) ?
#12
Closing this. Please reopen iv still relevant.