Breadcrumb control
Agaric would like breadcrumbs in Drupal to just work, but barring that until book navigation becomes general navigation in Drupal 6, we'd just like control...
Custom Breadcrumbs module
http://drupal.org/project/custom_breadcrumbs
From the PHP snippet section...
Breadcrumbs including title
Display full Breadcrumb in node
How to remove "blogs » user's blog" from breadcrumbs
Agaric's searches:
drupal taking control of breadcrumbs
take control of drupal breadcrumbs in the theme
theme drupal breadcrumbs
breadcrumbs for menu
http://api.drupal.org/api/function/theme_breadcrumb/5
Rejected approach... reaccepted approach...
<?php
if (arg(0) == 'showyoursupport') {
}
elseif (
arg(0) == 'view' && arg(1) == 'membervideos') {
}
elseif (
arg(0) == 'node' && arg(1) == 4) {
// Catalyst for a Cure
}
?>
http://drupal.org/project/taxonomy_context
node-breadcrumb
http://drupal.org/project/node_breadcrumb
http://drupal.org/project/custom_breadcrumbs
Instructions for using custom breadcrumbs?
http://drupal.org/node/122654#comment-517933
semantic html: theme_breadcrumb()
http://drupal.org/node/31776
Manipulating the Drupal Breadcrumb
http://projects.contentment.org/blog/83
http://lclive.openzuka.net/catalyst_for_a_cure
Test code first and then the result:
<?php
drupal_set_message('arg(0): '. arg(0));
drupal_set_message('arg(1): '. arg(1));
drupal_set_message('arg(2): '. arg(2));
drupal_set_message('arg(3): '. arg(3));
?>
* arg(0): node * arg(1): 4 * arg(2): * arg(3): *
<?php
drupal_set_message('<pre>'.print_r($breadcrumb,TRUE).'</pre>');
?>
Array ( [0] => Home )
<?php
drupal_set_message('<pre>'.print_r($menu = _menu_get_active_trail(),TRUE).'</pre>');
?>
* Array ( [0] => 2 [1] => 46 [2] => 251 [3] => -355 )
<?php
foreach ($menu as $mid) {
drupal_set_message($mid .'<pre>'.print_r(menu_get_item($mid),TRUE).'</pre>');
}
?>
# 2 Array ( [path] => [title] => Primary links [access] => 1 [type] => 115 [weight] => 0 [description] => [pid] => 0 [children] => Array ( [0] => 43 [1] => 46 [2] => 140 [3] => 160 [4] => 217 [5] => 244 ) ) # 46 Array ( [path] => node/894 [title] => Show Your Support [description] => [pid] => 2 [weight] => -1 [type] => 118 [children] => Array ( [0] => 198 [1] => 200 [2] => 251 ) ) # 251 Array ( [path] => node/4 [title] => Catalyst for a Cure [description] => [pid] => 46 [weight] => -8 [type] => 118 [access] => 1 [children] => Array ( [0] => -355 [1] => -356 [2] => -357 [3] => -358 [4] => -359 [5] => -373 ) ) # -355 Array ( [path] => node/4/view [title] => View [type] => 640 [weight] => -10 [pid] => 251 )
Preliminary version: structure for catching specific pages, and a rudimentary catch-all for pages with menu associations.
<?php
function phptemplate_breadcrumb($breadcrumb) {
// uncomment below to see what's available
/*
drupal_set_message('arg(0): '. arg(0));
drupal_set_message('arg(1): '. arg(1));
drupal_set_message('arg(2): '. arg(2));
drupal_set_message('arg(3): '. arg(3));
drupal_set_message('<pre>'.print_r($breadcrumb,TRUE).'</pre>');
*/
if (arg(0) == 'showyoursupport') {
}
/*
elseif (arg(0) == 'view' && arg(1) == 'membervideos') {
}
elseif (arg(0) == 'node' && arg(1) == 4) {
// Catalyst for a Cure
// this is actually done pretty well by the below
}
*/
elseif (count($breadcrumb) == 1) { // let's try to help it
$menu = _menu_get_active_trail();
array_pop($menu); // get rid of the last value, which is the current page
unset($menu[0]); // first one is usually no good either (Primary Links)
foreach ($menu as $mid) {
$item = menu_get_item($mid);
$breadcrumb[] = l($item['title'], $item['path']);
}
}
if (!empty($breadcrumb)) {
return '<div class="breadcrumb">'. implode(' » ', $breadcrumb) .'</div>';
}
}
?>
Comments
Post new comment