$term->tid, ); // @todo This overrides any other possible breadcrumb and is a pure hard-coded // presumption. Make this behavior configurable per vocabulary or term. $breadcrumb = array(); while ($parents = taxonomy_get_parents($current->tid)) { i18n_taxonomy_localize_terms($parents); $current = array_shift($parents); $breadcrumb[] = l($current->name, 'taxonomy/term/' . $current->tid); } $breadcrumb[] = l(t('Home'), NULL); $breadcrumb = array_reverse($breadcrumb); drupal_set_breadcrumb($breadcrumb); drupal_add_feed('taxonomy/term/' . $term->tid . '/feed', 'RSS - ' . $term->name); $build = array(); // Add term heading if the term has a description if (!empty($term->description)) { $build['term_heading'] = array( '#prefix' => '
', '#suffix' => '
', 'term' => taxonomy_term_view($term, 'full'), ); } if ($nids = taxonomy_select_nodes($term->tid, TRUE, variable_get('default_nodes_main', 10))) { $nodes = node_load_multiple($nids); $build += node_view_multiple($nodes); $build['pager'] = array( '#theme' => 'pager', '#weight' => 5, ); } else { $build['no_content'] = array( '#prefix' => '

', '#markup' => t('There is currently no content classified with this term.'), '#suffix' => '

', ); } return $build; } /** * Render a taxonomy term page HTML output. * * @param $tids * An array of term ids. * @param $result * A pager_query() result, such as that performed by taxonomy_select_nodes(). * * @ingroup themeable */ function theme_i18n_taxonomy_term_page($tids, $result) { drupal_add_css(drupal_get_path('module', 'taxonomy') .'/taxonomy.css'); $output = ''; // Only display the description if we have a single term, to avoid clutter and confusion. if (count($tids) == 1) { $term = taxonomy_get_term($tids[0]); if (i18n_taxonomy_vocabulary($term->vid) & I18N_MODE_LOCALIZE) { $description = i18n_string("taxonomy:term:$term->tid:description", $term->description); } else { $description = $term->description; } // Check that a description is set. if (!empty($description)) { $output .= '
'; $output .= filter_xss_admin($description); $output .= '
'; } } $output .= taxonomy_render_nodes($result); return $output; } /** * Helper function for autocompletion */ function i18n_taxonomy_autocomplete($vocabulary, $langcode, $tags_typed = '') { // The user enters a comma-separated list of tags. We only autocomplete the last tag. $tags_typed = drupal_explode_tags($tags_typed); $tag_last = drupal_strtolower(array_pop($tags_typed)); $matches = array(); if ($vocabulary && $langcode && $tag_last != '') { // Part of the criteria for the query come from the field's own settings. $vids = array($vocabulary->vid); $query = db_select('taxonomy_term_data', 't'); $query->addTag('translatable'); $query->addTag('term_access'); // Add language condition $query->condition('t.language', i18n_langcode($langcode)); // Do not select already entered terms. if (!empty($tags_typed)) { $query->condition('t.name', $tags_typed, 'NOT IN'); } // Select rows that match by term name. $tags_return = $query ->fields('t', array('tid', 'name')) ->condition('t.vid', $vids) ->condition('t.name', '%' . db_like($tag_last) . '%', 'LIKE') ->range(0, 10) ->execute() ->fetchAllKeyed(); $prefix = count($tags_typed) ? implode(', ', $tags_typed) . ', ' : ''; $term_matches = array(); foreach ($tags_return as $tid => $name) { $n = $name; // Term names containing commas or quotes must be wrapped in quotes. if (strpos($name, ',') !== FALSE || strpos($name, '"') !== FALSE) { $n = '"' . str_replace('"', '""', $name) . '"'; } else { $term_matches[$prefix . $n] = check_plain($name); } } } drupal_json_output($term_matches); }