User login

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

http://drupal.org/node/64067

Display full Breadcrumb in node

http://drupal.org/node/84206

How to remove "blogs » user's blog" from breadcrumbs

http://drupal.org/node/7399

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(' &raquo; ', $breadcrumb) .'</div>';
  }
}
?>

Comments

Post new comment

The content of this field is kept private and will not be shown publicly.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • You can use Markdown syntax to format and style the text. Also see Markdown Extra for tables, footnotes, and more.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <img> <blockquote> <small> <h2> <h3> <h4> <h5> <h6> <sub> <sup> <p> <br> <strike> <table> <tr> <td> <thead> <th> <tbody> <tt> <output>
  • Syntax highlight code surrounded by the {syntaxhighlighter SPEC}...{/syntaxhighlighter} tags, where SPEC is a Syntaxhighlighter options string or "class="OPTIONS" title="the title".
  • Lines and paragraphs break automatically.

More information about formatting options

By submitting this form, you accept the Mollom privacy policy.