ubc-web-services / Megatron

Drupal 7 theme for the UBC CLF
http://ubc-web-services.github.com/Megatron/
9 stars 8 forks source link

Empty delimiter in megatron_breadcrumb() #1

Closed reinette closed 11 years ago

reinette commented 11 years ago

On the site's home page only, the breadcrumb function gets upset, presumably because there's only one item to display. Warning: strpos() [function.strpos]: Empty delimiter in megatron_breadcrumb() (line 132 of sites/all/themes/megatron/template.php).

reinette commented 11 years ago

This sorted it for me:

diff --git a/template.php b/template.php
index 8aa89d9..3af2620 100644
--- a/template.php
+++ b/template.php
@@ -117,6 +117,7 @@ function megatron_breadcrumb($variables) {
   $breadcrumb = array_unique($breadcrumb);
   $breadcrumb[0] = ''; 
   $show_breadcrumb = theme_get_setting('breadcrumb_display');
+  $pos = FALSE;

   if ((!empty($breadcrumb)) && ($show_breadcrumb == 'yes')) {
     // Provide a navigational heading to give context for breadcrumb links to
@@ -128,8 +129,9 @@ function megatron_breadcrumb($variables) {
     $array_size = count($breadcrumb);
     $i = 0;
     while ( $i < $array_size) {
-    
-      $pos = strpos($breadcrumb[$i], drupal_get_title());
+      if(drupal_get_title()) {
+       $pos = strpos($breadcrumb[$i], drupal_get_title());
+      }
       //we stop duplicates entering where there is a sub nav based on page jumps
       if ($pos === false){
         $crumbs .= '<li class="breadcrumb-' . $i;
occupant commented 11 years ago

Fantastic, thanks for this - I hadn't had much chance to look at it yet. It's great to have another pair of eyes on this :)

I've committed the fix.

Cheers, James