Re: Re: Re: Mike,

Posts: 41
Joined: 09/07/2007

I finished my theme_uc_catalog_browse function. I found a module, Taxonomy Enhancer http://drupal.org/project/taxonomy_enhancer, that I am using instead of doing the hook_form_alter. It allows me to add a "Basic Description" field to my category terms. I'm just doing a database query to get the new field, but it works for what I need. I added some logic to determine how many blocks to fit into a row and also a little to determine if I want to print the category description above or below the category blocks. I don't have a live site up yet, you can see what it looks like here, http://www.xikar.com/redesign/Final_Site/Cigar_cutter_family_page.pdf and here, http://www.xikar.com/redesign/Final_Site/Xi1_model_page.pdf.

<?php
function xikar_uc_catalog_browse($tid = 0){
 
drupal_add_css(drupal_get_path('module', 'uc_catalog') .'/uc_catalog.css');
 
//clear $output
 
$output = '';
  if (
$catalog->image){
   
$output .= theme('imagecache', 'thumbnail', $catalog->image['filepath'], $catalog->name, $catalog->name, array('class' => 'category'));
  }
 
//load the catalog
 
$catalog = uc_catalog_get_page($tid);
  if(
$catalog->name == 'Catalog') {
   
drupal_set_title('The LED Christmas Light Experts');
  }
  else {
   
drupal_set_title($catalog->name);
  }

 
drupal_set_breadcrumb(uc_catalog_set_breadcrumb($catalog->tid));

 
$types = array_keys(uc_product_node_info());
 
$links = array();
 
$child_list = array();

 
//Categories with subcategories
 
$new_row = 0;
 
$count_row = 0;
 
$bottom_description = 0;
 
$top_description = 1;
  foreach(
$catalog->children as $category) {
    if(
$category->nodes >=1) {
      if(
$category->children != NULL) { // product category catalog pages
         
if($top_description == 1){
           
$output .= '<div id="products_description">' . $catalog->description . '</div>'; // category description text at top of page
       
}
        if(
$new_row == 1){
           
//do nothing
       
}else{ // open row div
           
$output .= '<div class="uc_catalog_subcategory_row">';
        }
       
$output .= '<div id="uc_catalog_subcategory_container">';
       
$output .= '<div class="uc_catalog_subcategory_link">'; // category image
       
$output .= l(theme('imagecache', 'product_list', $category->image['filepath'], $category->name, $category->name, array('class' => 'uc_catalog_subcategory_img')), taxonomy_term_path($category), array(), NULL, NULL, FALSE, TRUE) . '<br />' . '</div>';
       
$output .= '<div class="uc_catalog_subcategory_text">'; // category text and links
       
$output .= l($category->name, taxonomy_term_path($category)) . '<br />';
       
$output .= '<ul>';
       
$sub_val = 0;
        foreach(
$category->children as $subcategory) {
            if(
$sub_val >=6) { break;} // only show this many subcategories
           
$output .= '<li>' . l($subcategory->name, taxonomy_term_path($subcategory))."</li>\n";
           
$sub_val++;
        }
       
$output .= '</ul>';
       
$output .='<div class="uc_catalog_subcategory_see_more">' . l("See All $category->name", taxonomy_term_path($category), array(), NULL, NULL, FALSE, TRUE) . '</div></div>';
       
$output .= '<div class="clear"></div>';
       
$output .= '</div>';
        if(
$new_row == 1){ // after second block is printed, close the row div
             
$output .= '</div><br /><div class="clear"></div>';
            
$new_row = 0;
           
$count_row = 0;
        }else{
           
$new_row++;
           
$count_row = 1;
        }
       
$top_description = 0;
      }
     
// **************************
     
else { // product family catalog pages
       
if($new_row == 1){
           
//do nothing
       
}else{ // open row div
           
$output .= '<div class="uc_catalog_subcategory_row">';
        }
       
$output .= '<div id="uc_catalog_subcategory_container">';
       
$output .= '<div class="uc_catalog_subcategory_link">'; // category image
       
$output .= l(theme('imagecache', 'product_list', $category->image['filepath'], $category->name, $category->name, array('class' => 'uc_catalog_subcategory_img')), taxonomy_term_path($category), array(), NULL, NULL, FALSE, TRUE) . '<br />' . '</div>';
       
$output .= '<div class="uc_catalog_subcategory_text">'; // category text and links
       
$output .= l($category->name, taxonomy_term_path($category)) . '<br />' . db_result(db_query('SELECT value FROM taxonomy_enhancer_data WHERE tid = %d', $category->tid)) . '<div class="uc_catalog_subcategory_see_more">' . l('See All Models', taxonomy_term_path($category), array(), NULL, NULL, FALSE, TRUE) . '</div></div>';
       
$output .= '<div class="clear"></div>';
       
$output .= '</div>';
        if(
$new_row == 1){ // after second block is printed, close the row div
             
$output .= '</div><br /><div class="clear"></div>';
            
$new_row = 0;
           
$count_row = 0;
        }else{
           
$new_row++;
           
$count_row = 1;
        }
       
$bottom_description = 1;
      }
    }
  }
  if (
$count_row == 1){ // if there is only 1 block in the row, close the row div
     
$output .= '</div><br /><div class="clear"></div>';
  }
 
$product_query = taxonomy_select_nodes(array($catalog->tid));
 
$val = 0;
 
$product_types = array_keys(uc_product_node_info());
  while(
$products = db_fetch_object($product_query)) {
    if(
$product = node_load($products->nid)) {
     
$output .= node_view($product, TRUE)."\n";
     
$bottom_description = 1;
    }
  }
 
// if statement to print description at bottom
 
if($bottom_description == 1){
 
$output .= '<div id="products_description">' . $catalog->description . '</div>'; // category description text at bottom of page
 
}
 
$output .= $result;
  return
$output;
}
?>

Here's most of the CSS for this code:

/* Product Family Catalog Page Styles */
.uc_catalog_subcategory_row{
margin:1em 0 1em 0;
}
#uc_catalog_subcategory_container{
border:#fafafa solid 1px;
margin-right:1em;
width:16em;
float:left;
}
#uc_catalog_subcategory_container:hover{
border:#00539b solid 1px;
}
.uc_catalog_subcategory_link img{
width:100%; /* Allows image to scale with font size */
}
.uc_catalog_subcategory_link{
width:4.7em; /* Allows image to scale with font size */
float:left;
}
.uc_catalog_subcategory_text{
float:right;
padding-left:.5em;
width:10.25em;
height:7.8em;
}
.uc_catalog_subcategory_text ul{
margin:.5em 0 0 .25em;
font-size:.75em;
}
.uc_catalog_subcategory_text li{
margin:.25em 0 .25em 1em;
list-style-type:disc;
list-style-image: url('images/blue_bullet.gif');
}
.uc_catalog_subcategory_see_more{
text-align:right;
}
#products_description{
clear:both;
}
#products_description p{
margin:1em 0 0 0;
}
.clear{
clear:both;
}

Tableless catalog By: mikejoconnor (20 replies) Wed, 10/03/2007 - 08:04