Skip to content

Instantly share code, notes, and snippets.

@thsutton
Created October 28, 2010 06:08
Show Gist options
  • Save thsutton/650746 to your computer and use it in GitHub Desktop.
Save thsutton/650746 to your computer and use it in GitHub Desktop.
Handle <pathauto> more usefully in custom_breadcrumbs 1.5
This patch applied to Custom Breadcrumbs 1.5 and affects the way it processes
breadcrumb links when the user specifices `<pathauto>`: rather than cleaning
the whole path with *pathauto* (and thus killing any slashes), it passes *each
component* through.
Note that this is a bit of a hack: a robust implementation would clean the
substituted values as the path is being built. As it stands any `/`s in the
substituted values will remain in the output.
diff --git a/htdocs/sites/all/modules/contrib/custom_breadcrumbs/custom_breadcrumbs.module b/htdocs/sites/all/modules/contrib/custom_breadcrumbs/custom_breadcrumbs.module
index 83a507d..26d8c95 100644
--- a/htdocs/sites/all/modules/contrib/custom_breadcrumbs/custom_breadcrumbs.module
+++ b/htdocs/sites/all/modules/contrib/custom_breadcrumbs/custom_breadcrumbs.module
@@ -155,8 +155,15 @@ function _custom_breadcrumbs_create_crumb($title, $original_path) {
if ($path) {
switch ($identifier) {
case '<pathauto>':
- if (module_exists('pathauto'))
- $crumb = l($title, pathauto_cleanstring($path, FALSE));
+ if (module_exists('pathauto')) {
+ $components = array();
+ foreach (explode('/', $path) as $component) {
+ $components[] = pathauto_cleanstring($component, FALSE);
+ }
+ $path = implode('/', $components);
+ unset($components);
+ $crumb = l($title, $path);
+ }
break;
default:
$crumb = l($title, $original_path);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment