From dd42a41881896d0a7714aa94cea2be025683fb93 Mon Sep 17 00:00:00 2001 From: Colan Schwartz Date: Mon, 24 Sep 2012 10:52:59 -0400 Subject: [PATCH] Issue #1154608 by Mirabuck, martysteer, colan: Added support for external URLs. --- .../custom_breadcrumbs_external.info | 7 +++ .../custom_breadcrumbs_external.module | 54 ++++++++++++++++++++ 2 files changed, 61 insertions(+), 0 deletions(-) create mode 100644 custom_breadcrumbs_external/custom_breadcrumbs_external.info create mode 100644 custom_breadcrumbs_external/custom_breadcrumbs_external.module diff --git a/custom_breadcrumbs_external/custom_breadcrumbs_external.info b/custom_breadcrumbs_external/custom_breadcrumbs_external.info new file mode 100644 index 0000000..968721a --- /dev/null +++ b/custom_breadcrumbs_external/custom_breadcrumbs_external.info @@ -0,0 +1,7 @@ +name = Custom breadcrumbs for external URL paths +description = Provides identifiers to allow for custom breadcrumbs for external paths. +package = Custom breadcrumbs +core = 7.x +dependencies[] = custom_breadcrumbs +dependencies[] = custom_breadcrumbs_identifiers +files[] = custom_breadcrumbs_identifiers.module diff --git a/custom_breadcrumbs_external/custom_breadcrumbs_external.module b/custom_breadcrumbs_external/custom_breadcrumbs_external.module new file mode 100644 index 0000000..fcbb56d --- /dev/null +++ b/custom_breadcrumbs_external/custom_breadcrumbs_external.module @@ -0,0 +1,54 @@ +'] = t('Produces a link to an external site.'); + return $identifiers; +} + +/** + * Implements hook_cb_identifier_values(). + * + * This function prepares an array of crumb items to replace an identifier. + * The identifier should be a string starting with '<' and ending with '>'. + * The function also requires an object to make the substitution. Usually, + * this object will include the crumb title and path, but may contain other + * properties that can be used. + * + * This function returns an array of crumb items. Each crumb item is an + * associative array with keys + * 'crumb' = the html crumb to use in the breadcrumb + * 'title' = the title of the crumb + * 'href' = the link path + */ +function custom_breadcrumbs_external_cb_identifier_values($identifier, $obj) { + $crumb_items = NULL; + switch ($identifier) { + case '': + + // Add double slashes to links. + $extpath = preg_replace('/:\//', '://', $obj['path']); + $crumb = l($obj['title'], $extpath, $obj['attributes']); + $crumb_item = array( + 'crumb' => $crumb, + 'title' => $obj['title'], + 'href' => $extpath, + ); + $crumb_items[] = $crumb_item; + break; + } + return $crumb_items; +} + -- 1.7.0.4