<div dir="ltr"><div><div>I'm posting this here instead of the theme list because even though this would typically be needed in a theme, it's not about theming, per se.<br><br></div>I struggled [way too long] today to generate a full category breadcrumb. Yes, I know, this type of thing has been asked and answered ad nauseum. The difference here is that the point at which I need the breadcrumb (eg grandparent category / parent category / category) is in a field template for a field that appears in the node display ... so long before $breadcrumb becomes available during the page render.<br>
<br></div>What I ended up with is the following. I do plan on moving the code, so no need to flame me on having it in the template. :-) I'd like to know if there's an easier way to do it ... "Oh, you could have just called blah blah" ... I promise not to cry... much.<br>
<br> <?php $parents = taxonomy_get_parents($variables['element']['#object']->field_product_category['und'][0]['tid']); ?><br> <?php $breadcrumb = drupal_get_breadcrumb(); ?><br>
<?php foreach($parents as $parent): ?><br> <?php $breadcrumb[] = $parent->name; ?><br> <?php endforeach; ?><br> <?php $breadcrumb[] = $variables['element']['#object']->field_product_category['und'][0]['taxonomy_term']->name; ?><br>
<?php print theme('breadcrumb', array('breadcrumb'=>$breadcrumb)); ?><br><br><br clear="all"><div><div><div><br>-- <br>---<div><a href="http://drupal.org/user/367108" target="_blank">drupal.org/user/367108</a></div>
<div><a href="http://linkedin.com/in/jeffrgreenberg" target="_blank">linkedin.com/in/jeffrgreenberg</a></div><div><a href="http://accidentalcoder.com" target="_blank">accidentalcoder.com</a> / <a href="http://ayendesigns.com" target="_blank">ayendesigns.com</a></div>
<div>@accidentalcoder</div>
</div></div></div></div>