Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Display a formatted list of products.
- *
- * @param $products
- * An array of product nids.
- * @ingroup themeable
- */
- function theme_uc_catalog_products($products) {
- if (!$products) {
- $output .= '<div class="no-products">'. t('No products are available in this category.') .'</div>';
- return $output;
- }
- else {
- if (variable_get('uc_catalog_grid_display', FALSE)) {
- return theme('uc_catalog_product_grid', $products);
- }
- else {
- $table = tapir_get_table('uc_product_table', $products);
- return drupal_render($table);
- }
- }
- }
- /**
- * Display a list of products in grid format().
- *
- * @ingroup themeable
- */
- function theme_uc_catalog_product_grid($products) {
- $product_table = '<div class="category-grid-products"><table>';
- $count = 0;
- $context = array(
- 'revision' => 'themed',
- 'type' => 'product',
- );
- foreach ($products as $nid) {
- $product = node_load($nid);
- $context['subject'] = array('node' => $product);
- if ($count == 0) {
- $product_table .= "<tr>";
- }
- elseif ($count % variable_get('uc_catalog_grid_display_width', 3) == 0) {
- $product_table .= "</tr><tr>";
- }
- $titlelink = l($product->title, "node/$nid", array('html' => TRUE));
- if (module_exists('imagecache') && ($field = variable_get('uc_image_'. $product->type, '')) && isset($product->$field) && file_exists($product->{$field}[0]['filepath'])) {
- $imagelink = l(theme('imagecache', 'product_list', $product->{$field}[0]['filepath'], $product->title, $product->title), "node/$nid", array('html' => TRUE));
- }
- else {
- $imagelink = '';
- }
- $product_table .= '<td>';
- if (variable_get('uc_catalog_grid_display_title', TRUE)) {
- $product_table .= '<span class="catalog-grid-title">'. $titlelink .'</span>';
- }
- if (variable_get('uc_catalog_grid_display_model', TRUE)) {
- $product_table .= '<span class="catalog-grid-ref">'. $product->model .'</span>';
- }
- $product_table .= '<span class="catalog-grid-image">'. $imagelink .'</span>';
- if (variable_get('uc_catalog_grid_display_sell_price', TRUE)) {
- $product_table .= '<span class="catalog-grid-sell-price">'. uc_price($product->sell_price, $context) .'</span>';
- }
- if (module_exists('uc_cart') && variable_get('uc_catalog_grid_display_add_to_cart', TRUE)) {
- if (variable_get('uc_catalog_grid_display_attributes', TRUE)) {
- $product_table .= theme('uc_product_add_to_cart', $product);
- }
- else {
- $product_table .= drupal_get_form('uc_catalog_buy_it_now_form_'. $product->nid, $product);
- }
- }
- $product_table .= '</td>';
- $count++;
- }
- $product_table .= "</tr></table></div>";
- return $product_table;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement