Commit 51168507 authored by Shrikey's avatar Shrikey
Browse files

Added imagecache dependency.

Added new imagecache preset.
Removed css from template file in a seperate css file.
Added check for image field in template file.
parent 4a1ef3e1
Loading
Loading
Loading
Loading
+7 −19
Original line number Diff line number Diff line
@@ -12,11 +12,14 @@
  <div id="products">
  <?php foreach($products as $product): ?>
    <div class="object">
      <?php if (isset($product->field_image)): ?>
      <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>
        <?php print l(theme(
                'imagecache', 'uc_catalog_template', $product->field_image[0]['filepath'], 
                $product->title, $product->title), 
                'node/'.$product->nid, array('html' => fals)); ?>
      </div>
      <?php endif; ?>
      <div class="title">
        <?php print l($product->title, 'node/'.$product->nid); ?>
      </div>
@@ -32,7 +35,7 @@
    <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); ?>
          <?php print theme('imagecache', 'uc_catalog_template', $cat->image['filepath'], $cat->name, $cat->name); ?>
        </a>
      </div>
      <div class="title"><?php print l($cat->name, 'catalog/'.$cat->tid); ?></div>
@@ -42,18 +45,3 @@
  <?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; }
*/
?>
+8 −0
Original line number Diff line number Diff line
#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 .image img { margin:2px; }
#catalog .title { margin:5px 0 0 2px; }
#catalog .title a { color:#363E41; text-decoration:none; }
#catalog .price { margin-left:2px; }
+2 −1
Original line number Diff line number Diff line
@@ -3,3 +3,4 @@ description = Show the Ubercart catalog using a template.
version = 1.0
core = 6.x
dependencies[] = uc_catalog
dependencies[] = imagecache
+28 −4
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',
@@ -19,11 +15,39 @@ function uc_catalog_template_theme_registry_alter(&$theme_registry) {
  }
}

/**
 * Implementation of hook_imagecache_default_presets().
 */
function uc_catalog_template_imagecache_default_presets() {
  $presets = array();

  $presets['uc_catalog_template'] = array(
    'presetname' => 'uc_catalog_template',
    'actions' => array(
      array(
        'weight' => '0',
        'module' => 'uc_catalog_template',
        'action' => 'imagecache_scale_and_crop',
        'data' => array(
          'width' => '166',
          'height' => '166',
          'upscale' => 0,
        ),
      ),
    ),
  );

  return $presets;
}

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));
  $path = drupal_get_path('module', 'uc_catalog_template');
  drupal_add_css($path .'/uc_catalog_template.css', 'module', 'all', FALSE);
  
  $types = uc_product_types();
  $sub_categories = $catalog->children;
  unset($catalog->children);