Loading ubercart_catalog.tpl.php 0 → 100644 +59 −0 Original line number Diff line number Diff line <?php /* Available variables: * * $catalog: Current term * $sub_categories => Child terms of current term * $products => Products within the current term. Number of products are defined in 'uc_product_nodes_per_page' * $pager => Pager of products. */ ?> <div id="catalog"> <?php if($products): ?> <div id="products"> <?php foreach($products as $product): ?> <div class="object"> <div class="image"> <a href="/<?php print $product->path; ?>"> <?php print theme('imagecache', 'product_list', $product->field_image[0]['filepath'], $product->title, $product->title); ?> </a> </div> <div class="title"> <?php print l($product->title, 'node/'.$product->nid); ?> </div> <div class="sell-price"> <?php print uc_price($product->sell_price, array('subject'=>array('node'=>$product)), array('including-title' => false)); ?> </div> </div> <?php endforeach; ?> </div> <?php else: ?> <div id="sub-categories"> <?php foreach($sub_categories as $cat): ?> <div class="object"> <div class="image"> <a href="<?php print base_path() . 'catalog/'.$cat->tid; ?>"> <?php print theme('imagecache', 'product_list', $cat->image['filepath'], $cat->name, $cat->name); ?> </a> </div> <div class="title"><?php print l($cat->name, 'catalog/'.$cat->tid); ?></div> </div> <?php endforeach; ?> </div> <?php endif; ?> <?php print $pager; ?> </div> <?php /* Sample CSS #catalog { padding:20px 0 0; font-size:1.3em; overflow:hidden; } #catalog .object { float:left; margin:0 40px 30px 0; } #catalog .image { position:relative; width:170px; height:170px; } #catalog .image a { text-decoration:none; } #catalog .top-layer { position:absolute; background:url('../img/product-border-3px.png') no-repeat; width:170px; height:170px; top:0; } #catalog .image img { margin:2px; } #catalog .title { margin:5px 0 0 2px; } #catalog .title a { color:#363E41; text-decoration:none; } #catalog .price { margin-left:2px; } */ ?> uc_catalog_template.info 0 → 100644 +6 −0 Original line number Diff line number Diff line name = Ubercart catalog template description = Show the Ubercart catalog using a template. version = 1.0 core = 6.x dependencies[] = uc_catalog No newline at end of file uc_catalog_template.module 0 → 100644 +100 −0 Original line number Diff line number Diff line <?php function uc_catalog_template_theme($existing, $type, $theme, $path){ // ---------------- http://drupal.org/node/223463 // , $catalog, $sub_categories, $products, theme('pager') return array( 'ubercart_catalog' => array( 'template' => 'ubercart_catalog', 'arguments' => array('catalog' => null, 'sub_categories' => null, 'products' => null, 'pager' => null), ), ); } /* function uc_catalog_template_preprocess(&$vars, $hook) { if($hook=='ubercart-catalog') { $vars['template_files'][] = 'ubercart-catalog'; } }*/ function uc_catalog_template_theme_registry_alter(&$theme_registry) { if (!empty($theme_registry['uc_catalog_browse'])) { $theme_registry['uc_catalog_browse']['function'] = 'uc_catalog_template_uc_catalog_browse'; } } function uc_catalog_template_uc_catalog_browse($tid = 0) { $output = ''; $catalog = uc_catalog_get_page((int)$tid); drupal_set_title(check_plain($catalog->name)); drupal_set_breadcrumb(uc_catalog_set_breadcrumb($catalog->tid)); $types = uc_product_types(); $sub_categories = $catalog->children; unset($catalog->children); // Build an ORDER BY clause for the SELECT query based on table sort info. if (empty($_REQUEST['order'])) { $order = 'ORDER BY p.ordering, n.title, n.nid'; } else { $order = tapirsort_sql(uc_product_table_header()); } $sql = "SELECT DISTINCT(n.nid), n.sticky, n.title, n.created, p.model, p.sell_price, p.ordering FROM {node} n INNER JOIN {term_node} tn ON n.vid = tn.vid INNER JOIN {uc_products} AS p ON n.vid = p.vid WHERE tn.tid = %d AND n.status = 1 AND n.type IN (". db_placeholders($types, 'varchar') .") ". $order; $sql_count = "SELECT COUNT(DISTINCT(n.nid)) FROM {node} n INNER JOIN {term_node} tn ON n.vid = tn.vid INNER JOIN {uc_products} AS p ON n.vid = p.vid WHERE tn.tid = %d AND n.status = 1 AND n.type IN (". db_placeholders($types, 'varchar') .")"; $sql = db_rewrite_sql($sql); $sql_count = db_rewrite_sql($sql_count); $sql_args = array($catalog->tid); foreach ($types as $type) { $sql_args[] = $type; } $products = array(); $result = pager_query($sql, variable_get('uc_product_nodes_per_page', 12), 0, $sql_count, $sql_args); while ($node = db_fetch_object($result)) { $products[] = node_load($node->nid); } $output = theme('ubercart_catalog', $catalog, $sub_categories, $products, theme('pager')); return $output; } /** * Implementation of hook_form_alter(). */ function uc_catalog_template_form_alter(&$form, $form_state, $form_id) { if ($form_id == 'uc_catalog_settings_form') { $form['catalog-top-level']['uc_catalog_show_subcategories']['#disabled'] = TRUE; $form['catalog-top-level']['uc_catalog_category_columns']['#disabled'] = TRUE; drupal_set_message(t('The options "Display subcategories in the catalog view" and "Number of columns in the grid of categories" are irrelevant in combination with the module "Ubercart catalog template". To customize the catalog layout, copy @ubercart-catalog-template/ubercart-catalog.tpl.php to your theme and edit this.', array('@ubercart-catalog-template' => drupal_get_path('module', 'uc_catalog_template'))), 'warning', FALSE); } if ($form_id == 'uc_catalog_grid_settings_form') { unset($form["uc_catalog_grid_display"]); unset($form["uc_catalog_grid_display_width"]); unset($form["displayed_fields"]); unset($form["buttons"]); drupal_set_message(t('This page is irrelevant in combination with the module "Ubercart catalog template". To customize the catalog layout, copy @ubercart-catalog-template/ubercart-catalog.tpl.php to your theme and edit this.', array('@ubercart-catalog-template' => drupal_get_path('module', 'uc_catalog_template'))), 'warning', FALSE); } } Loading
ubercart_catalog.tpl.php 0 → 100644 +59 −0 Original line number Diff line number Diff line <?php /* Available variables: * * $catalog: Current term * $sub_categories => Child terms of current term * $products => Products within the current term. Number of products are defined in 'uc_product_nodes_per_page' * $pager => Pager of products. */ ?> <div id="catalog"> <?php if($products): ?> <div id="products"> <?php foreach($products as $product): ?> <div class="object"> <div class="image"> <a href="/<?php print $product->path; ?>"> <?php print theme('imagecache', 'product_list', $product->field_image[0]['filepath'], $product->title, $product->title); ?> </a> </div> <div class="title"> <?php print l($product->title, 'node/'.$product->nid); ?> </div> <div class="sell-price"> <?php print uc_price($product->sell_price, array('subject'=>array('node'=>$product)), array('including-title' => false)); ?> </div> </div> <?php endforeach; ?> </div> <?php else: ?> <div id="sub-categories"> <?php foreach($sub_categories as $cat): ?> <div class="object"> <div class="image"> <a href="<?php print base_path() . 'catalog/'.$cat->tid; ?>"> <?php print theme('imagecache', 'product_list', $cat->image['filepath'], $cat->name, $cat->name); ?> </a> </div> <div class="title"><?php print l($cat->name, 'catalog/'.$cat->tid); ?></div> </div> <?php endforeach; ?> </div> <?php endif; ?> <?php print $pager; ?> </div> <?php /* Sample CSS #catalog { padding:20px 0 0; font-size:1.3em; overflow:hidden; } #catalog .object { float:left; margin:0 40px 30px 0; } #catalog .image { position:relative; width:170px; height:170px; } #catalog .image a { text-decoration:none; } #catalog .top-layer { position:absolute; background:url('../img/product-border-3px.png') no-repeat; width:170px; height:170px; top:0; } #catalog .image img { margin:2px; } #catalog .title { margin:5px 0 0 2px; } #catalog .title a { color:#363E41; text-decoration:none; } #catalog .price { margin-left:2px; } */ ?>
uc_catalog_template.info 0 → 100644 +6 −0 Original line number Diff line number Diff line name = Ubercart catalog template description = Show the Ubercart catalog using a template. version = 1.0 core = 6.x dependencies[] = uc_catalog No newline at end of file
uc_catalog_template.module 0 → 100644 +100 −0 Original line number Diff line number Diff line <?php function uc_catalog_template_theme($existing, $type, $theme, $path){ // ---------------- http://drupal.org/node/223463 // , $catalog, $sub_categories, $products, theme('pager') return array( 'ubercart_catalog' => array( 'template' => 'ubercart_catalog', 'arguments' => array('catalog' => null, 'sub_categories' => null, 'products' => null, 'pager' => null), ), ); } /* function uc_catalog_template_preprocess(&$vars, $hook) { if($hook=='ubercart-catalog') { $vars['template_files'][] = 'ubercart-catalog'; } }*/ function uc_catalog_template_theme_registry_alter(&$theme_registry) { if (!empty($theme_registry['uc_catalog_browse'])) { $theme_registry['uc_catalog_browse']['function'] = 'uc_catalog_template_uc_catalog_browse'; } } function uc_catalog_template_uc_catalog_browse($tid = 0) { $output = ''; $catalog = uc_catalog_get_page((int)$tid); drupal_set_title(check_plain($catalog->name)); drupal_set_breadcrumb(uc_catalog_set_breadcrumb($catalog->tid)); $types = uc_product_types(); $sub_categories = $catalog->children; unset($catalog->children); // Build an ORDER BY clause for the SELECT query based on table sort info. if (empty($_REQUEST['order'])) { $order = 'ORDER BY p.ordering, n.title, n.nid'; } else { $order = tapirsort_sql(uc_product_table_header()); } $sql = "SELECT DISTINCT(n.nid), n.sticky, n.title, n.created, p.model, p.sell_price, p.ordering FROM {node} n INNER JOIN {term_node} tn ON n.vid = tn.vid INNER JOIN {uc_products} AS p ON n.vid = p.vid WHERE tn.tid = %d AND n.status = 1 AND n.type IN (". db_placeholders($types, 'varchar') .") ". $order; $sql_count = "SELECT COUNT(DISTINCT(n.nid)) FROM {node} n INNER JOIN {term_node} tn ON n.vid = tn.vid INNER JOIN {uc_products} AS p ON n.vid = p.vid WHERE tn.tid = %d AND n.status = 1 AND n.type IN (". db_placeholders($types, 'varchar') .")"; $sql = db_rewrite_sql($sql); $sql_count = db_rewrite_sql($sql_count); $sql_args = array($catalog->tid); foreach ($types as $type) { $sql_args[] = $type; } $products = array(); $result = pager_query($sql, variable_get('uc_product_nodes_per_page', 12), 0, $sql_count, $sql_args); while ($node = db_fetch_object($result)) { $products[] = node_load($node->nid); } $output = theme('ubercart_catalog', $catalog, $sub_categories, $products, theme('pager')); return $output; } /** * Implementation of hook_form_alter(). */ function uc_catalog_template_form_alter(&$form, $form_state, $form_id) { if ($form_id == 'uc_catalog_settings_form') { $form['catalog-top-level']['uc_catalog_show_subcategories']['#disabled'] = TRUE; $form['catalog-top-level']['uc_catalog_category_columns']['#disabled'] = TRUE; drupal_set_message(t('The options "Display subcategories in the catalog view" and "Number of columns in the grid of categories" are irrelevant in combination with the module "Ubercart catalog template". To customize the catalog layout, copy @ubercart-catalog-template/ubercart-catalog.tpl.php to your theme and edit this.', array('@ubercart-catalog-template' => drupal_get_path('module', 'uc_catalog_template'))), 'warning', FALSE); } if ($form_id == 'uc_catalog_grid_settings_form') { unset($form["uc_catalog_grid_display"]); unset($form["uc_catalog_grid_display_width"]); unset($form["displayed_fields"]); unset($form["buttons"]); drupal_set_message(t('This page is irrelevant in combination with the module "Ubercart catalog template". To customize the catalog layout, copy @ubercart-catalog-template/ubercart-catalog.tpl.php to your theme and edit this.', array('@ubercart-catalog-template' => drupal_get_path('module', 'uc_catalog_template'))), 'warning', FALSE); } }