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
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

budda - September 18, 2006 - 16:38

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

Shane Birley - October 12, 2006 - 15:51

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

msameer - January 15, 2007 - 23:44
Version:HEAD» 5.x-1.0

#4

msameer - January 19, 2007 - 18:14

I can't reproduce this with the 5.x-1.0
Can you please test it ? or are you still using 4.7 ?

#5

davinder - January 22, 2007 - 18:39

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

msameer - January 23, 2007 - 20:49

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

stalefishlabs - February 6, 2007 - 09:34

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

budda - February 15, 2007 - 14:31

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

ztnews - February 15, 2007 - 22:48
Version:5.x-1.0» 4.7.x-1.x-dev

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

msameer - March 1, 2007 - 20:42

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

msameer - March 3, 2007 - 17:49

Can you please test with 4.7.x-1.2 (http://drupal.org/node/124444) ?

#12

msameer - September 26, 2007 - 21:04
Status:needs work» closed

Closing this. Please reopen iv still relevant.

 
 

Drupal is a registered trademark of Dries Buytaert.