Hi,

I have nodes organised in taxonomy term structures e.g.

computers
- laptops
--13''
--15''
--17''
- desktops

Now those pages that belong to the lowest level only show the top level of the taxonomy. For instance a 13'' laptop has the breadcrumb
home>laptop
instead of
home>laptop>13''

How can I solve this?

Comments

donquixote’s picture

Hi,
I agree with your request.

The current logic works like this:
- starting with a node (the 13" Laptop), the taxonomy.termReference.xyz plugin will pick the first term that it can find. In your case, this is just "laptops".
- "laptops" is already at the top of the hierarchy, so the parent of that is "home".

A solution would be, if the taxonomy.termReference.xyz plugin would not pick the first term that it can find, but the one with the highest depth.

I am playing with this now..

donquixote’s picture

Btw, why is your node tagged as laptops and 13'' ? Does the 13'' category not already imply the laptops category?

brianlp’s picture

Yes that's right, it does.

But I need to tag it all the way, ohterwise the node wouldn't show up on the taxonomy category pages. (Click on "laptops" should show all laptops.)

donquixote’s picture

Can you try something?

file: plugins/crumbs.taxonomy.inc,
class: _taxonomy_CrumbsMultiPlugin_termReference
replace the _findParentPath() method:

  protected function _findParentPath($entity) {
    if (isset($entity->{$this->fieldKey})) {
      $field = $entity->{$this->fieldKey};
      $terms = array();
      foreach (array(
        'und',
        $GLOBALS['language']->language,
      ) as $lang) {
        if (!empty($lang) && isset($field[$lang])) {
          foreach ($field[$lang] as $term_info) {
            $terms[$term_info['tid']] = TRUE;
          }
        }
      }
      if (count($terms) > 1) {
        $walk = $terms;
        $visited = array();
        while (!empty($walk)) {
          $visited += $walk;
          foreach ($walk as $tid => $true) {
            $parents = taxonomy_get_parents($tid);
            unset($walk[$tid]);
            foreach ($parents as $tid => $parent) {
              unset($terms[$tid]);
              if (!isset($visited[$tid])) {
                $walk[$tid] = $parent;
              }
            }
          }
        }
      }
      if (!empty($terms)) {
        foreach ($terms as $tid => $term_info) {
          return 'taxonomy/term/' . $tid;
        }
      }
    }
  }
brianlp’s picture

Hm, actually it takes away the base category. It sets the breadcrumb to "Home".

To be honest, I'm not a skilled programmer. I have replaced this (line 76-82)

function findParent__node_x($path, $item) {
    $node = $item['map'][1];
    $parent_path = $this->_findParentPath($node);
    if ($parent_path) {
      return array($node->type => $parent_path);
    }
  }

In the crumbs settings I use

taxonomy.termReference.*
menu.*
path

donquixote’s picture

Hmmm nope. You replaced the wrong thing.

Ok, I think I should make a real patch out of this.

donquixote’s picture

Status: Active » Needs review
StatusFileSize
new1.51 KB

Here is a patch.

brianlp’s picture

Yup, perfect. Now it is the ultimate breadcrumb machine.

Months of headache are gone. Thank you so much!

I have switched the priorities to first grab everything that is assigned to a menu and then the taxonomy structure for non-menu items. Otherwise the blog entries would now get the taxonomy breadcrumb.

menu.*
taxonomy.termReference.*

donquixote’s picture

Status: Needs review » Fixed

This looks very committed already :)

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.