You are here

function crumbs_CrumbsMultiPlugin_nodeParent::findParent__node_x in Crumbs, the Breadcrumbs suite 7

File

plugins/crumbs.crumbs.inc, line 50

Class

crumbs_CrumbsMultiPlugin_nodeParent

Code

function findParent__node_x($path, $item) {
  global $language;
  $node = $item['map'][1];

  // Load the node if it hasn't been loaded due to a missing wildcard loader.
  $node = is_numeric($node) ? node_load($node) : $node;
  $pattern = @$this->patterns[$node->type];
  if (!empty($pattern)) {
    if (module_exists('token')) {
      $parent = token_replace($pattern, array(
        'node' => $node,
      ), array(
        'language' => $language,
        'callback' => 'crumbs_clean_token_values',
      ));
    }
    else {
      $parent = $pattern;
    }
    if (!empty($parent)) {

      // Only accept candidates where all tokens are fully resolved.
      // This means we can't have literal '[' in the path - so be it.
      if (FALSE === strpos($parent, '[')) {
        return array(
          $node->type => $parent,
        );
      }
    }
  }
}