? 643796_cb_classes_v2.diff
? CHANGELOG.txt
? FAQ.txt
Index: custom_breadcrumbs.admin.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/custom_breadcrumbs/custom_breadcrumbs.admin.inc,v
retrieving revision 1.1.2.3.2.23
diff -u -r1.1.2.3.2.23 custom_breadcrumbs.admin.inc
--- custom_breadcrumbs.admin.inc	30 Nov 2009 00:09:55 -0000	1.1.2.3.2.23
+++ custom_breadcrumbs.admin.inc	29 Jan 2010 03:14:41 -0000
@@ -262,6 +262,13 @@
     '#weight'        => -50,
   );
 
+  $cbid = custom_breadcrumbs_unique_breadcrumb_id($breadcrumb->breadcrumb_type, $breadcrumb->bid);
+  if (isset($cbid)) {
+    $form['classid'] = array(
+      '#value'       => '<strong>'. t('The CSS class name for this breadcrumb is !name', array('!name' => $cbid)) .'</strong>',
+    );
+  }
+
   $multilingual = _custom_breadcrumbs_multilingual();
   if ($multilingual) {
     $form['language'] = array(
@@ -464,6 +471,53 @@
     '#description'   => t("A comma delimited set of paths to exclude from custom breadcrumbs. The '*' character can be used as a wildcard."),
   );
 
+  $form['adv_settings']['custom_breadcrumbs_identifiers'] = array(
+    '#type'          => 'fieldset',
+    '#title'         => t('HTML element identifiers'),
+    '#description'   => t("Enabling one or more of these options will provide html identifiers (class or id) for theming custom breadcrumbs links. Style rules can then be defined in the styles.css file located in the site's theme directory."),
+    '#collapsible'   => TRUE,
+    '#collapsed'     => FALSE,
+  );
+
+  $form['adv_settings']['custom_breadcrumbs_identifiers']['cb_identifier_options'] = array(
+    '#type'          => 'fieldset',
+    '#collapsible'   => FALSE,
+  );
+
+  $form['adv_settings']['custom_breadcrumbs_identifiers']['cb_identifier_options']['custom_breadcrumbs_home_id'] = array(
+    '#type'          => 'checkbox',
+    '#title'         => t("Add a custom-breadcrumbs-home ID attribute to the home breadcrumb item."),
+    '#default_value' => variable_get('custom_breadcrumbs_home_id', FALSE),
+  );
+
+  $form['adv_settings']['custom_breadcrumbs_identifiers']['cb_identifier_options']['custom_breadcrumbs_parts_class'] = array(
+    '#type'          => 'checkbox',
+    '#title'         => t("Add a numbered class attribute for each breadcrumb item."),
+    '#description'   => t("If enabled, a custom-breadcrumbs-item-N class attribute will be assigned for each item, where N designates the item number, starting with the first item after the home breadcrumb."),
+    '#default_value' => variable_get('custom_breadcrumbs_parts_class', FALSE),
+  );
+
+  $form['adv_settings']['custom_breadcrumbs_identifiers']['cb_identifier_options']['custom_breadcrumbs_even_odd_class'] = array(
+    '#type'          => 'checkbox',
+    '#title'         => t("Add custom-breadcrumbs-even and custom-breadcrumbs-odd classes to breadcrumb items."),
+    '#default_value' => variable_get('custom_breadcrumbs_even_odd_class', FALSE),
+  );
+
+  $form['adv_settings']['custom_breadcrumbs_identifiers']['cb_identifier_options']['custom_breadcrumbs_type_class'] = array(
+    '#type'          => 'checkbox',
+    '#title'         => t("Store an identifier for breadcrumb theming."),
+    '#description'   => t("If enabled, the breadcrumb class 'custom-breadcrumbs-<em>type</em>' (where <em>type</em> is module, node, panels, path, views, taxonomy_term, taxonomy_vocabulary, taxonomy, etc.) can be retrieved and used in the breadcrumb theme override. The function <strong>custom_breadcrumbs_unique_breadcrumb_id()</strong> will return a string containing the id name."),
+    '#default_value' => variable_get('custom_breadcrumbs_type_class', FALSE),
+  );
+
+  $form['adv_settings']['custom_breadcrumbs_identifiers']['cb_identifier_options']['custom_breadcrumbs_append_bid_class'] = array(
+    '#type'          => 'checkbox',
+    '#title'         => t("Append a unique breadcrumb id number to the custom-breadcrumbs-<em>type</em> identifier."),
+    '#description'   => t("If this option and 'Store an identifier for breadcrumb theming' are both enabled, the identifer will be custom-breadcrumbs-<em>type</em>-<em>id</em>, where id is the unique breadcrumb id number."),
+    '#default_value' => variable_get('custom_breadcrumbs_append_bid_class', FALSE),
+    '#disabled'      => !variable_get('custom_breadcrumbs_type_class', FALSE),
+  );
+
   $form['adv_settings']['module_weights'] = array(
     '#type'          => 'fieldset',
     '#title'         => t('Module weights'),
Index: custom_breadcrumbs.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/custom_breadcrumbs/custom_breadcrumbs.module,v
retrieving revision 1.6.2.5.2.32
diff -u -r1.6.2.5.2.32 custom_breadcrumbs.module
--- custom_breadcrumbs.module	20 Jan 2010 00:06:21 -0000	1.6.2.5.2.32
+++ custom_breadcrumbs.module	29 Jan 2010 03:14:41 -0000
@@ -302,7 +302,9 @@
       $title = trim($titles[$i]);
       if (($title != '') && ($title != '<none>')) {
         // Create breadcrumb only if there is a title.
-        $trail[] = _custom_breadcrumbs_create_crumb($title, trim($paths[$i]));
+        // Include optional html attributes.
+        $options = _custom_breadcrumbs_identifiers_option($breadcrumb->breadcrumb_type, $i+1, $breadcrumb->bid);
+        $trail[] = _custom_breadcrumbs_create_crumb($title, trim($paths[$i]), $options);
         $location[] = array('title' => $title, 'href' => drupal_get_normal_path(trim($paths[$i])));
       }
     }
@@ -310,6 +312,34 @@
       menu_set_active_trail($location);
     }
     drupal_set_breadcrumb($trail);
+    // Optionally save the unique breadcrumb id of the last set breadcrumb.
+    custom_breadcrumbs_unique_breadcrumb_id($breadcrumb->breadcrumb_type, $breadcrumb->bid);
+  }
+}
+
+/**
+ *  Set or get the unique breadcrumb id.
+ *
+ *  @param $breadcrumb
+ *    The breadcrumb object used to set the unique breadcrumb id.
+ *
+ *  @return $cbid
+ *    A string containing the unique id for this breadcrumb
+ */
+function custom_breadcrumbs_unique_breadcrumb_id($type = NULL, $bid = NULL) {
+  if (variable_get('custom_breadcrumbs_type_class', FALSE)) {
+    if (isset($type)) {
+      $base = 'custom-breadcrumbs';
+      $cbid = $base .'-'. $type;
+      if (variable_get('custom_breadcrumbs_append_bid_class', FALSE) && isset($bid)) {
+        $cbid .= '-'. $bid;
+      }
+      variable_set('custom_breadcrumbs_breadcrumb_id', $cbid);
+    }
+    else {
+      $cbid = variable_get('custom_breadcrumbs_breadcrumb_id', NULL);
+    }
+  return $cbid;
   }
 }
 
@@ -392,7 +422,9 @@
 function custom_breadcrumbs_home_crumb() {
   $hometext = variable_get('custom_breadcrumb_home', t('Home'));
   if ($hometext != '') {
-    $trail = array(l($hometext, '<front>'));
+    // Add any html identifiers.
+    $options = _custom_breadcrumbs_identifiers_option();
+    $trail = array(l($hometext, '<front>', $options));
   }
   else {
     $trail = array();
@@ -407,11 +439,13 @@
  *   The human readable title to be rendered by the browser.
  * @param $original_path
  *   The desired URI and/or special identifier.
+ * @param $attr
+ *   An associative array containing the HTML attributes to apply to the anchor tag.
  *
  * @return
  *   An HTML string containing a link to the original path.
  */
-function _custom_breadcrumbs_create_crumb($title, $original_path) {
+function _custom_breadcrumbs_create_crumb($title, $original_path, $attr = array()) {
   // Decode title to properly handle special characters.
   $title = decode_entities($title);
   // Collapse double slashes to one.
@@ -421,6 +455,7 @@
   list($identifier, $path) = explode("|", $original_path, 2);
   if (isset($path) && $path !== '') {
     $options = parse_url($path);
+    $options = array_merge($options, $attr);
     switch (trim($identifier)) {
       case '<pathauto>':
         if (module_exists('pathauto')) {
@@ -435,6 +470,7 @@
   else {
     // This may be just be a single identifier.
     $options = parse_url($original_path);
+    $options = array_merge($options, $attr);
     switch ($identifier) {
       case '<none>':
         $crumb = check_plain($title);
@@ -943,3 +979,36 @@
   }
   return FALSE;
 }
+
+/**
+ * Helper function to add optional html identifers to breadcrumb links.
+ *
+ * @param $type
+ *   The breadcrumb type.
+ * @param $bid
+ *   The breadcrumb id.
+ * @param $part
+ *   A postive integer indicating the breadcrumb segment (home crumb = 0).
+ *
+ * @return
+ *   An associative array containing the HTML attributes to apply to the anchor tag.
+ */
+function _custom_breadcrumbs_identifiers_option($type = NULL, $part = 0, $bid = NULL) {
+  $options = array('attributes' => array());
+  $classes = array();
+  $base = 'custom-breadcrumbs';
+  if (variable_get('custom_breadcrumbs_home_id', FALSE) && ($part == 0)) {
+    $options['attributes']['id'] = $base .'-home';
+  }
+  elseif (variable_get('custom_breadcrumbs_parts_class', FALSE) && ($part > 0)) {
+    $classes[] = $base .'-item-'. $part;
+  }
+  if (variable_get('custom_breadcrumbs_even_odd_class', FALSE)) {
+    $class = ($part % 2 == 0) ? 'even' : 'odd';
+    $classes[] = $base .'-'. $class;
+  }
+  if (!empty($classes)) {
+    $options['attributes']['class'] = implode(' ', $classes);
+  }
+  return $options;
+}
Index: custom_breadcrumbs_taxonomy/custom_breadcrumbs_taxonomy.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/custom_breadcrumbs/custom_breadcrumbs_taxonomy/Attic/custom_breadcrumbs_taxonomy.inc,v
retrieving revision 1.1.2.12
diff -u -r1.1.2.12 custom_breadcrumbs_taxonomy.inc
--- custom_breadcrumbs_taxonomy/custom_breadcrumbs_taxonomy.inc	10 Jan 2010 22:36:41 -0000	1.1.2.12
+++ custom_breadcrumbs_taxonomy/custom_breadcrumbs_taxonomy.inc	29 Jan 2010 03:14:41 -0000
@@ -42,7 +42,6 @@
   return $output;
 }
 
-
 /**
  *  Helper function to set the breadcrumb using a node's taxonomy.
  *
@@ -67,6 +66,8 @@
       $breadcrumb[] = $objs['node']->title;
     }
     drupal_set_breadcrumb($breadcrumb);
+    // Optionally save the unique breadcrumb id of the last set breadcrumb.
+    custom_breadcrumbs_unique_breadcrumb_id('taxonomy');
   }
   else {
     global $language;
@@ -243,12 +244,12 @@
   $trail = _custom_breadcrumbs_taxonomy_home_trail();
 
   if (!is_null($vocabid)) {
-    $vocab_trail = _custom_breadcrumbs_taxonomy_vocabulary_trail($vocabid, $is_term_page, $objs, $types);
+    $vocab_trail = _custom_breadcrumbs_taxonomy_vocabulary_trail($vocabid, $is_term_page, $objs, $types, count($trail));
     $trail = array_merge($trail, $vocab_trail);
   }
 
   if (!is_null($tid)) {
-    $term_trail = _custom_breadcrumbs_taxonomy_term_trail($tid, $is_term_page, $objs, $types);
+    $term_trail = _custom_breadcrumbs_taxonomy_term_trail($tid, $is_term_page, $objs, $types, count($trail));
     $trail = array_merge($trail, $term_trail);
     // Optionally remove the current TERM from end of breadcrumb trail.
     if ((!variable_get('custom_breadcrumbs_taxonomy_show_current_term', TRUE) || ($is_term_page && !variable_get('custom_breadcrumbs_taxonomy_show_current_term_term', TRUE))) && (count($trail) > 1)) {
@@ -299,24 +300,27 @@
  * @return
  *   The breadcrumb trail.
  */
-function _custom_breadcrumbs_taxonomy_vocabulary_trail($vid, $is_term_page = FALSE, $objs = array(), $types = array('global' => NULL)) {
+function _custom_breadcrumbs_taxonomy_vocabulary_trail($vid, $is_term_page = FALSE, $objs = array(), $types = array('global' => NULL), $part = 1) {
   // Generate the VOCABULARY breadcrumb.
   $trail = array();
   // Check to see if a vocabulary breadcrumb exists.
   $breadcrumbs = custom_breadcrumbs_load_breadcrumbs('custom_breadcrumbs_taxonomy', 'custom_breadcrumbs_taxonomy_vocabulary', array('vid' => $vid));
   $vocabulary_path = NULL;
+  $bid = NULL;
   if ($breadcrumb = custom_breadcrumbs_select_breadcrumb($breadcrumbs, $objs)) {
     $vocabulary_path = $breadcrumb->paths;
+    $bid = $breadcrumb->bid;
     if (module_exists('token')) {
       $vocabulary_path = token_replace_multiple($vocabulary_path, $types);
     }
   }
   if ($vocabulary = taxonomy_vocabulary_load($vid)) {
     if ($vocabulary_path != NULL) {
-      $trail = array(l(_custom_breadcrumbs_taxonomy_tt("taxonomy:vocabulary:$vid:name", $vocabulary->name), $vocabulary_path));
+      $options = _custom_breadcrumbs_identifiers_option('taxonomy_vocabulary', $part, $bid);
+      $trail = array(l(_custom_breadcrumbs_taxonomy_tt("taxonomy:vocabulary:$term->tid:name", $vocabulary->name), $vocabulary_path, $options));
     }
     elseif (variable_get('custom_breadcrumbs_taxonomy_show_vocabulary', FALSE)) {
-      $trail = array(_custom_breadcrumbs_taxonomy_tt("taxonomy:vocabulary:$vid:name", $vocabulary->name));
+      $trail = array(_custom_breadcrumbs_taxonomy_tt("taxonomy:vocabulary:$term->tid:name", $vocabulary->name));
     }
   }
   return $trail;
@@ -337,15 +341,17 @@
  * @return
  *   The breadcrumb trail.
  */
-function _custom_breadcrumbs_taxonomy_term_trail($tid, $is_term_page = FALSE, $objs = array(), $types = array('global' => NULL)) {
+function _custom_breadcrumbs_taxonomy_term_trail($tid, $is_term_page = FALSE, $objs = array(), $types = array('global' => NULL), $part = 1) {
   // Generate the TERM breadcrumb.
   $trail = array();
   $parent_terms = array_reverse(taxonomy_get_parents_all($tid));
   foreach ($parent_terms as $parent_term) {
     $breadcrumbs = custom_breadcrumbs_load_breadcrumbs('custom_breadcrumbs_taxonomy', 'custom_breadcrumbs_taxonomy_term', array('tid' => $parent_term->tid));
     $term_path = NULL;
+    $bid = NULL;
     if ($breadcrumb = custom_breadcrumbs_select_breadcrumb($breadcrumbs, $objs)) {
       $term_path = $breadcrumb->paths;
+      $bid = $breadcrumb->bid;
       if (module_exists('token')) {
         $term_path = token_replace_multiple($term_path, $types);
       }
@@ -353,13 +359,16 @@
     if ($term_path == NULL) {
       $term_path = taxonomy_term_path(taxonomy_get_term($parent_term->tid));
     }
+
     // Do not create links to own self if we are on a taxonomy/term page.
     if ($is_term_page && $parent_term->tid == $tid) {
       $trail[] = _custom_breadcrumbs_taxonomy_tt("taxonomy:term:$parent_term->tid:name", $parent_term->name);
     }
     else {
-      $trail[] = l(_custom_breadcrumbs_taxonomy_tt("taxonomy:term:$parent_term->tid:name", $parent_term->name), $term_path);
+      $options = _custom_breadcrumbs_identifiers_option('taxonomy_term', $part, $bid);
+      $trail[] = l(_custom_breadcrumbs_taxonomy_tt("taxonomy:term:$parent_term->tid:name", $parent_term->name), $term_path, $options);
     }
+    ++$part;
   }
   return $trail;
 }
