Posted by Andrew Kaufmann on May 11, 2011 at 10:19pm
8 followers
| Project: | Custom Breadcrumbs |
| Version: | 7.x-2.x-dev |
| Component: | custom_breadcrumbs |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | needs review |
Issue Summary
Hey there -
I've tested this in both 2.0-rc1 and 2.0-dev, I'm having the same problem in both.
I'm trying to set the root of the breadcrumb to an external URL. I've entered the URL as "http://www.blahblah.com/stuff" and instead of it going to the URL, it interprets it as a Drupal URL after chopping off the http://. So, it turns into "http://www.my.site/www.blahblah.com/stuff".
I read a post that says that external URLs should work, so I've categorized this as a bug report. Even though it might be a feature request. :)
Thanks!
Comments
#1
Hello,
I needed this feature as well (our multisite install points to a central site at the top of breadcrumbs).
I created a small module and used hook_cb_identifier_list() and hook_cb_identifier_values() to look at adding this functionality. I'm finding though that external URLs coming into hook_cb_identifier_values() via $obj have a / missing so that they're rendered as http:/www.mylink.something. I wondered if it might be related.
Many thanks!
#2
Custom breadcrumbs assumes the paths are internal drupal paths by design. I think the identifier approach that Mirabuck is describing would work well for this.
@Mirabuck, if you would like to post your code, I would be happy to look it over and consider integrating it into the cb_identifiers module if there is interest.
#3
Hi MGN,
There isn't much to it, but here it is:
<?php
// $Id: test_breadcrumb
/**
* @file
* Provides a special identifier for custom breadcrumbs to allow for external links.
*
*/
/**
* Implements hook_cb_identifier_list().
*
* @return
* An array of text strings describing special identifier behavoir.
*/
function test_breadcrumb_cb_identifier_list() {
$identifiers = array();
$identifiers['<external>'] = 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 test_breadcrumb_cb_identifier_values($identifier, $obj) {
$crumb_items = NULL;
switch ($identifier) {
case '<external>':
//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;
}
#4
subscribe
#5
Here is a drop in module based on Mirabuck's code. Works pretty well as far as I can tell.
#6
Any chance of getting this working in Drupal 7? I don't have an external url, but the url token I'm using is giving an absolute URL instead of just the local Drupal path, and I have no way of getting just the Drupal path to show up in the breadcrumb.
EDIT: It looks like the drop-in module is already for Drupal 7, even though this issue was brought up in the Drupal 6 version. Also, the 7.2 version supports book hierarchy already, so I didn't need this module. I guess this post was just pointless after all!
#7
Putting this in proper patch format for review.
#8
Trying to apply the patch in #7 I got the error "corrupt patch at line 72". I've re-created the patch.