This is a clarification of a comment I originally made in #256225: White space improperly converted?. I am reposting this with additional information because in retrospect I am not sure if it actually related to the original problem described there after all.

I do not get correct breadcrumb paths when using [bookpath-raw].

(Drupal 6.3, pathauto 6.x.1.1, token 6.x.1.11, custom breadcrumbs 6.x-1.3)

Create a book with two (book page) child pages:
top level book
middle level book
bottom level book

The automated pathauto pattern for book pages is [bookpath-raw]/[title-raw].
Pathauto correctly gives all of the url aliases, replacing spaces with dashes (as I have it configured):

.../top-level-book
.../top-level-book/middle-level-book
.../top-level-book/middle-level-book/bottom-level-book

The configuration for custom breadcrumbs path for book pages is:

book
[bookpath-raw]
node/[nid]

Selecting the last portion of the breadcrumb yields the correct url (dashes instead of spaces):

../top-level-book/middle-level-book/bottom-level-book

However, selecting the middle portion of the breadcrumb (corresponding to [bookpath-raw] yields breadcrumb urls like

.../top level book/middle level book

notice the spaces...I think these should be dashes. Everything would work as intended if those spaces would be replaced with dashes.

Since the aliases are being correctly created by pathauto using the [bookpath-raw] token, I figure it may be a bug in custom breadcrumbs?

Any help or advice on how to further clarify this problem would be appreciated!

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

MGN’s picture

Here is a patch that fixes this problem, originally contributed for 5.x in #289810: Special Behaviors by jmstacey. I just reformated it so that I could apply it to 6.x-1.3. Its a nice patch which will clean the path according to pathauto rules when an identifier <pathauto>| is prefixed to the path. Also includes help documentation on the custom breadcrumbs admin form.

Now when I use <pathauto>|[bookpath-raw] for the custom breadcrumbs path setting, the breadcrumb works as expected!

I have it working on several sites Drupal 6.3 sites now and haven't had any problems.

MGN’s picture

Status: Active » Needs review

Oops.... Forgot to change the status.

babbage’s picture

I have reviewed this patch and have tested it. I recommend it be committed to custom_breadcrumbs.

I believe this issue is an important one and is one that has been reported by other users and is an issue I myself faced. The solution makes good use of existing functionality provided by the pathauto module specifically for the current purpose—of cleaning paths using pathauto settings.

I reviewed this code to confirm it was a good solution to the problem. I then re-rolled the patch for 6.x-1.x-dev (2008-Oct-17), and tested it against Drupal 6.6 in both a clean install with no other modules installed (other than Administration Menu) and against a development server version of a fully configured site. The patch provides the planned functionality which works as proposed.

In addition to re-rolling the patch for the current dev version of custom_breadcrumbs, I also:

  • partially re-wrote the help text in the administration interface for the modification to more clearly describe the functionality.
  • noted in the help text the additional option of using the identifier <none> which was not previously documented.
  • made the Special Identifiers fieldset non-collapsible since it was not large and Drupal contains too many collapsed fieldsets already.
  • re-ordered the final items in the administration interface so that Override menu path appears first, the Special identifiers is second, and Placeholder tokens last, simply since the latter is so large once it is displayed in full and thus this arrangement is tidier.

(Title of thread edited to better reflect nature of patch.)

babbage’s picture

Title: whitespace not converted with [bookpath-raw] token in path » Clean path using pathauto function
Version: 6.x-1.3 » 6.x-1.x-dev
Category: bug » feature
FileSize
5.15 KB

It appears editing my comment removed the attached patch—or I just didn't attach it. Either way, here it is. :)

babbage’s picture

Status: Needs review » Reviewed & tested by the community

No activity for a couple of weeks here and this patch appears to work well so will mark as RTBC in the hope of getting this committed or at least reviewed by a maintainer.

thePanz’s picture

Status: Reviewed & tested by the community » Needs work

Hi, your patch is great, I'd like to point that this patch doesn't deal with "pathauto change case" changing.

I edited custom_breadcrumbs.module to have, near line 147 this code:

        if (module_exists('pathauto')) {
          $path = pathauto_cleanstring($path, FALSE);
          
          if (variable_get('pathauto_case', 1))
            $path = drupal_strtolower($path);
            
          $crumb = l($title, $path);

Now custom_breadcrumbs generates URLs in lowercase if pathauto is setted to do that.
Regards

babbage’s picture

Status: Needs work » Reviewed & tested by the community

@thePanz: the issue you raise resulted from a bug in Pathauto not with Custom Breadcrumbs, and that bug has already been fixed in #343851: pathauto_cleanstring() does not convert to lowercase (consolidate all text altering code to pathauto_cleanstring) though that patch has not yet been committed. Thus, the change you suggest is not required. Reverting to RTBC.

thePanz’s picture

@dbabbage: you're right! the patch you pointed is the right solution! Thank you!
Regards

babbage’s picture

thePanz’s picture

ehehe, you're right :) I just noticed issue's author name ;)
but... is pathauto 2.x usable for a "stable" use? Your patch in #343851: pathauto_cleanstring() does not convert to lowercase (consolidate all text altering code to pathauto_cleanstring) referres to 2.x-dev release and I'm using latest 1.x!
Sorry for my [OT] :)

babbage’s picture

I am just one user of Pathauto but I am using the -dev version (with my patch obviously) and it has been rock solid--but I suggest check the issue queue and see if anything of concern.

nitrospectide’s picture

Title: Clean path using pathauto function » patch for 6.x-1.4?
Version: 6.x-1.x-dev » 6.x-1.4

I tried running this patch against both 6.x-1.4 and the 6.x-1.dev version but get an error:

-bash: syntax error near unexpected token `newline'

Am I doing something wrong, or is the problem that the codebase has changed and the patch needs updating?

MGN’s picture

What command syntax are you using to apply the patch? Thats not the kind of error you would get if the codebase was modified. Seems like you didn't give the correct patch command... See http://drupal.org/node/60108. Hope this helps!

nitrospectide’s picture

Ah! I am still new to patching. I ran it this time without the -p0, and it worked.

Now, I am getting a glitch. I have this line in my paths window:

blogs/myblog/
|[title-raw]

and when I click the associated crumb on the page, it links me to:

http://www.mysite.net/blogs/myblog/
|Episode 33

It doesn't seem to be interpreting it. I know the patch worked, because the helper text explaining the pipe syntax is at the bottom of the screen - but something else seems to be amiss.

MGN’s picture

Title: patch for 6.x-1.4? » Clean path using pathauto function
Version: 6.x-1.4 » 6.x-1.x-dev

I think you are forgetting the
identifier before the pipe - check the example again... Also, put the identifier at the begining of the path, like this:

<pathauto>|blogs/myblog/[title-raw]

Hope this helps!

Changing the name and version back so we don't get confused... Hopefully, someday, we will be able to commit this patch...

nitrospectide’s picture

Thanks!

I just noticed that the identifier did not paste in for some reason when I posted last night. My code should have read:

blogs/myblog/<pathauto>|[title-raw]

And here's the rub - the example in the help text doe not show a multi-part path. It only shows a single-part path. So I was under the impression that you had to put the identifier and pipe immediately before the single element you wanted cleaned - not in front of the entire path. As I reread now, I see where I missed it, but think this was perhaps easy to misunderstand. I recommend changing the help text to clarify that the identifier and pipe should pre-pend the whole path by showing a multipart example.

Now I just have to get PathAuto patched to make things lowercase...

MGN’s picture

I agree we need to work on the documentation here.

MGN’s picture

Status: Reviewed & tested by the community » Fixed

Committed to 6.x-1.x-dev.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.