commerce_kickstart_taxonomy.module in Commerce Kickstart 7.2
File
modules/commerce_kickstart/commerce_kickstart_taxonomy/commerce_kickstart_taxonomy.module
View source
<?php
function commerce_kickstart_taxonomy_preprocess_page(&$variables) {
$router_item = menu_get_item(current_path());
$machine_name = variable_get('commerce_kickstart_demo_store', FALSE) ? 'collection' : 'product_category';
if ($router_item['path'] == $machine_name . '/%') {
$variables['title'] = '';
}
}
function commerce_kickstart_taxonomy_taxonomy_menu_path() {
$output = array(
'commerce_kickstart_taxonomy_term_path' => t('Commerce Kickstart Taxonomy'),
);
return $output;
}
function commerce_kickstart_taxonomy_theme(&$existing) {
$themes = array(
'views_view__collection_products__page' => array(
'path' => drupal_get_path('module', 'commerce_kickstart_taxonomy') . '/theme',
'template' => 'views-view--collection-products--page',
'arguments' => array(
'view' => NULL,
),
'base hook' => 'views_view',
),
);
return $themes;
}
function commerce_kickstart_taxonomy_preprocess_views_view(&$vars) {
$view = $vars['view'];
if ($view->name == 'collection_products') {
if ($view->current_display == 'page') {
$vars['classes_array'][] = 'view-collection-taxonomy-term';
$tid = $view->args['0'];
$term = taxonomy_term_load($tid);
$vars['collection_title'] = $term->name;
$vars['collection_image_url'] = NULL;
if (!empty($term->field_image) && !empty($term->field_image[LANGUAGE_NONE][0]['uri'])) {
$vars['collection_image_url'] = file_create_url($term->field_image[LANGUAGE_NONE][0]['uri']);
}
}
}
}
function commerce_kickstart_taxonomy_entity_info_alter(&$entity_info) {
$entity_info['taxonomy_term']['uri callback'] = 'commerce_kickstart_taxonomy_term_uri';
}
function commerce_kickstart_taxonomy_term_uri($taxonomy_term) {
$uri = 'taxonomy/term/' . $taxonomy_term->tid;
$machine_name = variable_get('commerce_kickstart_demo_store', FALSE) ? 'collection' : 'product_category';
if ($taxonomy_term->vocabulary_machine_name == $machine_name) {
$uri = $taxonomy_term->vocabulary_machine_name . '/' . $taxonomy_term->tid;
}
return array(
'path' => $uri,
);
}
function commerce_kickstart_taxonomy_term_path($vid, $tid) {
$vocabulary = taxonomy_vocabulary_load($vid);
if ($vocabulary) {
if ($tid == 0) {
$vtids = _taxonomy_menu_get_terms($vid);
$end = implode(' ', $vtids);
$path = $vocabulary->machine_name . '/' . $end;
}
else {
$path = $vocabulary->machine_name . '/' . $tid;
if (variable_get(_taxonomy_menu_build_variable('display_descendants', $vid), FALSE)) {
if (variable_get(_taxonomy_menu_build_variable('end_all', $vid), FALSE)) {
$path .= '/all';
}
else {
$terms = taxonomy_get_tree($vid, $tid);
foreach ($terms as $term) {
$tids[] = $term->tid;
}
if ($tids) {
$end = implode(' ', $tids);
$path .= ' ' . $end;
}
}
}
}
return $path;
}
else {
return taxonomy_menu_path_default($vid, $tid);
}
}
function commerce_kickstart_taxonomy_views_api() {
return array(
'api' => 3,
'path' => drupal_get_path('module', 'commerce_kickstart_taxonomy') . '/includes/views',
);
}