You are here

function image_gallery_nodeapi in Image 6

Same name and namespace in other branches
  1. 5.2 contrib/image_gallery/image_gallery.module \image_gallery_nodeapi()
  2. 5 contrib/image_gallery/image_gallery.module \image_gallery_nodeapi()
  3. 7 contrib/image_gallery/image_gallery.module \image_gallery_nodeapi()

Implementation of hook_nodeapi().

File

contrib/image_gallery/image_gallery.module, line 115

Code

function image_gallery_nodeapi(&$node, $op, $teaser = NULL, $page = NULL) {
  switch ($op) {
    case 'view':
      if ($page && !$teaser && $node->type == 'image') {
        $vid = _image_gallery_get_vid();
        $terms = taxonomy_node_get_terms_by_vocabulary($node, $vid);
        $term = array_pop($terms);
        if ($term) {
          $vocabulary = taxonomy_vocabulary_load($vid);

          // Breadcrumb navigation
          $breadcrumb = array();
          $breadcrumb[] = l(t('Home'), NULL);
          $breadcrumb[] = l($vocabulary->name, 'image');
          if ($parents = taxonomy_get_parents_all($term->tid)) {
            $parents = array_reverse($parents);
            foreach ($parents as $parent) {
              $breadcrumb[] = l($parent->name, 'image/tid/' . $parent->tid);
            }
          }
          drupal_set_breadcrumb($breadcrumb);
        }
      }
      break;
  }
}