Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.74 KB | None | 0 0
  1. /**
  2.  * Display a formatted list of products.
  3.  *
  4.  * @param $products
  5.  *   An array of product nids.
  6.  * @ingroup themeable
  7.  */
  8. function theme_uc_catalog_products($products) {
  9.   if (!$products) {
  10.     $output .= '<div class="no-products">'. t('No products are available in this category.') .'</div>';
  11.     return $output;
  12.   }
  13.   else {
  14.     if (variable_get('uc_catalog_grid_display', FALSE)) {
  15.       return theme('uc_catalog_product_grid', $products);
  16.     }
  17.     else {
  18.       $table = tapir_get_table('uc_product_table', $products);
  19.       return drupal_render($table);
  20.     }
  21.   }
  22. }
  23.  
  24. /**
  25.  * Display a list of products in grid format().
  26.  *
  27.  * @ingroup themeable
  28.  */
  29. function theme_uc_catalog_product_grid($products) {
  30.   $product_table = '<div class="category-grid-products"><table>';
  31.   $count = 0;
  32.   $context = array(
  33.     'revision' => 'themed',
  34.     'type' => 'product',
  35.   );
  36.   foreach ($products as $nid) {
  37.     $product = node_load($nid);
  38.     $context['subject'] = array('node' => $product);
  39.  
  40.     if ($count == 0) {
  41.       $product_table .= "<tr>";
  42.     }
  43.     elseif ($count % variable_get('uc_catalog_grid_display_width', 3) == 0) {
  44.       $product_table .= "</tr><tr>";
  45.     }
  46.  
  47.     $titlelink = l($product->title, "node/$nid", array('html' => TRUE));
  48.     if (module_exists('imagecache') && ($field = variable_get('uc_image_'. $product->type, '')) && isset($product->$field) && file_exists($product->{$field}[0]['filepath'])) {
  49.       $imagelink = l(theme('imagecache', 'product_list', $product->{$field}[0]['filepath'], $product->title, $product->title), "node/$nid", array('html' => TRUE));
  50.     }
  51.     else {
  52.       $imagelink = '';
  53.     }
  54.  
  55.     $product_table .= '<td>';
  56.     if (variable_get('uc_catalog_grid_display_title', TRUE)) {
  57.       $product_table .= '<span class="catalog-grid-title">'. $titlelink .'</span>';
  58.     }
  59.     if (variable_get('uc_catalog_grid_display_model', TRUE)) {
  60.       $product_table .= '<span class="catalog-grid-ref">'. $product->model .'</span>';
  61.     }
  62.     $product_table .= '<span class="catalog-grid-image">'. $imagelink .'</span>';
  63.     if (variable_get('uc_catalog_grid_display_sell_price', TRUE)) {
  64.       $product_table .= '<span class="catalog-grid-sell-price">'. uc_price($product->sell_price, $context) .'</span>';
  65.     }
  66.     if (module_exists('uc_cart') && variable_get('uc_catalog_grid_display_add_to_cart', TRUE)) {
  67.       if (variable_get('uc_catalog_grid_display_attributes', TRUE)) {
  68.         $product_table .= theme('uc_product_add_to_cart', $product);
  69.       }
  70.       else {
  71.         $product_table .= drupal_get_form('uc_catalog_buy_it_now_form_'. $product->nid, $product);
  72.       }
  73.     }
  74.     $product_table .= '</td>';
  75.  
  76.     $count++;
  77.   }
  78.   $product_table .= "</tr></table></div>";
  79.   return $product_table;
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement