Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

[Contribution] Product Short Descriptions


Guest

Recommended Posts

I have installed the Product Short Descriptions And have tried to get the short description to display under the product code and product name, but I've not quite got there.

 

Please take a look at my Cylinder Trolleys Product Listing Page to see where I'm upto with it.

 

Heres my modules/product_listing.php code please have a scan through it an tell me where I'm being stupid :blink: thanks for any help with this:

 

<?php
/*
 $Id: product_listing.php,v 1.44 2003/06/09 22:49:59 hpdl Exp $

 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License
*/

 $listing_split = new splitPageResults($listing_sql, MAX_DISPLAY_SEARCH_RESULTS, 'p.products_id');

 if ( ($listing_split->number_of_rows > 0) && ( (PREV_NEXT_BAR_LOCATION == '1') || (PREV_NEXT_BAR_LOCATION == '3') ) ) {
?>
<table border="0" width="100%" cellspacing="0" cellpadding="2">
 <tr>
   <td class="smallText"><?php echo $listing_split->display_count(TEXT_DISPLAY_NUMBER_OF_PRODUCTS); ?></td>
   <td class="smallText" align="right"><?php echo TEXT_RESULT_PAGE . ' ' . $listing_split->display_links(MAX_DISPLAY_PAGE_LINKS, tep_get_all_get_params(array('page', 'info', 'x', 'y'))); ?></td>
 </tr>
</table>
<?php
 }

 $list_box_contents = array();

 for ($col=0, $n=sizeof($column_list); $col<$n; $col++) {
   switch ($column_list[$col]) {
     case 'PRODUCT_LIST_MODEL':
       $lc_text = TABLE_HEADING_MODEL;
       $lc_align = '';
       break;
     case 'PRODUCT_LIST_NAME':
       $lc_text = TABLE_HEADING_PRODUCTS;
       $lc_align = '';
       break;
 case 'PRODUCT_LIST_INFO':
       $lc_text = TABLE_HEADING_INFO;
       $lc_align = '';
       break;
     case 'PRODUCT_LIST_MANUFACTURER':
       $lc_text = TABLE_HEADING_MANUFACTURER;
       $lc_align = '';
       break;
     case 'PRODUCT_LIST_PRICE':
       $lc_text = TABLE_HEADING_PRICE;
       $lc_align = 'right';
       break;
     case 'PRODUCT_LIST_QUANTITY':
       $lc_text = TABLE_HEADING_QUANTITY;
       $lc_align = 'right';
       break;
     case 'PRODUCT_LIST_WEIGHT':
       $lc_text = TABLE_HEADING_WEIGHT;
       $lc_align = 'right';
       break;
     case 'PRODUCT_LIST_IMAGE':
       $lc_text = TABLE_HEADING_IMAGE;
       $lc_align = 'center';
       break;
     case 'PRODUCT_LIST_BUY_NOW':
       $lc_text = TABLE_HEADING_BUY_NOW;
       $lc_align = 'center';
       break;
   }

   // Products Description Hack begins
   if ($column_list[$col] != 'PRODUCT_LIST_BUY_NOW' &&
       $column_list[$col] != 'PRODUCT_LIST_IMAGE' &&
       $column_list[$col] != 'PRODUCT_LIST_INFO')
     $lc_text = tep_create_sort_heading($HTTP_GET_VARS['sort'], $col+1, $lc_text);

   if ($column_list[$col] != 'PRODUCT_LIST_INFO') {
     $list_box_contents[0][] = array('align' => $lc_align,
                                            'params' => 'class="productListing-heading"',
                                            'text'  => " " . $lc_text . " ");
   }

 }
   // Products Description Hack ends

 if ($listing_split->number_of_rows > 0) {
   $rows = 0;
   $listing_query = tep_db_query($listing_split->sql_query);
   while ($listing = tep_db_fetch_array($listing_query)) {
     $rows++;

     if (($rows/2) == floor($rows/2)) {
       $list_box_contents[] = array('params' => 'class="productListing-even"');
     } else {
       $list_box_contents[] = array('params' => 'class="productListing-odd"');
     }

     $cur_row = sizeof($list_box_contents) - 1;

     for ($col=0, $n=sizeof($column_list); $col<$n; $col++) {
       $lc_align = '';
 // Products Description Hack begins
       $lc_params = '';
       // Products Description Hack ends

       switch ($column_list[$col]) {
         case 'PRODUCT_LIST_MODEL':
           $lc_align = '';
           $lc_text = ' ' . $listing['products_model'] . ' ';
           break;
         case 'PRODUCT_LIST_NAME':
           $lc_align = '';
           if (isset($HTTP_GET_VARS['manufacturers_id'])) {
             $lc_text = '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id'] . '&products_id=' . $listing['products_id']) . '">' . $listing['products_name'] . '</a>';
           } else {
             $lc_text = ' <a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing['products_id']) . '">' . $listing['products_name'] . '</a> ';
           }
	 break;
	 // Products Description Hack begins
         case 'PRODUCT_LIST_INFO':
           $lc_text = $listing['products_info'] . ' ';
           $col_to_span = sizeof($column_list)-1;
           if (PRODUCT_LIST_IMAGE > 0) {
             $col_to_span -= 1;
           }
           $lc_params = 'colspan="' . $col_to_span . '" ';
           break;
         // Products Description Hack ends
           
	 // case 'PRODUCT_LIST_INFO':
          // $lc_align = '';
         //  $lc_text = $listing['products_info'] . ' ';
         //  break;
         case 'PRODUCT_LIST_MANUFACTURER':
           $lc_align = '';
           $lc_text = ' <a href="' . tep_href_link(FILENAME_DEFAULT, 'manufacturers_id=' . $listing['manufacturers_id']) . '">' . $listing['manufacturers_name'] . '</a> ';
           break;
         case 'PRODUCT_LIST_PRICE':
           $lc_align = 'right';
           if (tep_not_null($listing['specials_new_products_price'])) {
             $lc_text = ' <s>' .  $currencies->display_price($listing['products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</s>  <span class="productSpecialPrice">' . $currencies->display_price($listing['specials_new_products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</span> ';
           } else {
             $lc_text = ' ' . $currencies->display_price($listing['products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . ' ';
           }
           break;
         case 'PRODUCT_LIST_QUANTITY':
           $lc_align = 'right';
           $lc_text = ' ' . $listing['products_quantity'] . ' ';
           break;
         case 'PRODUCT_LIST_WEIGHT':
           $lc_align = 'right';
           $lc_text = ' ' . $listing['products_weight'] . ' ';
           break;
         case 'PRODUCT_LIST_IMAGE':
           $lc_align = 'center';
           if (isset($HTTP_GET_VARS['manufacturers_id'])) {
             $lc_text = '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id'] . '&products_id=' . $listing['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $listing['products_image'], $listing['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a>';
           } else {
             $lc_text = ' <a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $listing['products_image'], $listing['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a> ';
           }
	 // Products Description Hack begins
           if (PRODUCT_LIST_INFO > 0) {
             $lc_params = 'rowspan="2" ';
           }
           // Products Description Hack ends
           break;
                   case 'PRODUCT_LIST_BUY_NOW':
         $lc_align = 'center';
         $lc_text = '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $listing['products_id']) . '">' . tep_image_button('button_more_info.gif', IMAGE_BUTTON_MORE_INFO) . '</a><br><a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action', 'pName')) . 'action=buy_now&products_id=' . $listing['products_id']) . '">' . tep_image_button('button_buy_now.gif', IMAGE_BUTTON_BUY_NOW) . '</a> ';
         break;}

       // Products Description Hack begins
       $lc_params .= 'class="productListing-data"';
       if ($column_list[$col] == 'PRODUCT_LIST_INFO') {
         $list_box_contents[$cur_row][] = array('align' => $lc_align,
                                                'params' => $lc_params,
                                                'text' => $lc_text,
                                                'desc_flag' => 'true');
       } else {
         $list_box_contents[$cur_row][] = array('align' => $lc_align,
                                                'params' => $lc_params,
                                                'text'  => $lc_text);
       }
       // Products Description Hack ends
     }
   }

   new productListingBox($list_box_contents);
 } else {
   $list_box_contents = array();

   $list_box_contents[0] = array('params' => 'class="productListing-odd"');
   $list_box_contents[0][] = array('params' => 'class="productListing-data"',
                                  'text' => TEXT_NO_PRODUCTS);

   new productListingBox($list_box_contents);
 }

 if ( ($listing_split->number_of_rows > 0) && ((PREV_NEXT_BAR_LOCATION == '2') || (PREV_NEXT_BAR_LOCATION == '3')) ) {
?>
<table border="0" width="100%" cellspacing="0" cellpadding="2">
 <tr>
   <td width="33%" class="smallText"><?php echo $listing_split->display_count(TEXT_DISPLAY_NUMBER_OF_PRODUCTS); ?></td>
<?php
    	 $back = sizeof($navigation->path)-2;
     if (isset($navigation->path[$back])) {
  	 ?>
<td width="34%" align="center" class="main"><?php echo '<a href="' . tep_href_link($navigation->path[$back]['page'], tep_array_to_string($navigation->path[$back]['get'], array('action')), $navigation->path[$back]['mode']) . '">' . tep_image_button('button_back.gif', IMAGE_BUTTON_BACK) . '</a>'; ?></td>
<?php } else {?>
               <td width="34%" align="center" class="main"><a href="javascript:history.go(-1)"><?php echo tep_image_button('button_back.gif', IMAGE_BUTTON_BACK); ?></a></td>
   <?php
  	 }
  	 ?>
   <td width="33%" align="right" class="smallText"><?php echo TEXT_RESULT_PAGE . ' ' . $listing_split->display_links(MAX_DISPLAY_PAGE_LINKS, tep_get_all_get_params(array('page', 'info', 'x', 'y'))); ?></td>
 </tr>
</table>
<?php
 }
?>

Link to comment
Share on other sites

What I need is for the short description to span below the code and product name only, at the moment its spanning code, name, price and buy now. The price and buy now / more info need to span both rows just like the product image does.

 

Please please please help :thumbsup:

 

Oh and while I'm on the subject, whats the easiest way to get a space, a line and then another space between the product listings, just so it defines them a little more.

 

Come on you OSC Guru's.... Code Me Happy :D

Edited by Rochdalemark
Link to comment
Share on other sites

Sorry dont know the answer to your question, but I have one for you!

 

Did you use a contrib for the tabs on your site? And if you did then which one?

 

 

The tabs are just html copied into the header of my oscommerce, the actual contribution is part of my Xoops side of the site. All i did is copy the source code output for that into osc header.

Link to comment
Share on other sites

Forgot to add that in catalog/includes/classes/boxes.php

 

I found the following

if (is_array($contents[$i][0])) {
         for ($x=0, $n2=sizeof($contents[$i]); $x<$n2; $x++) {

 

and place the following code below it

 

if ($contents[$i][$x]['desc_flag'] == 'true') {
             $tableBox_string .= '  </tr>' . "\n";
             $tableBox_string .= '  <tr';
             if ($this->table_row_parameters != '') $tableBox_string .= ' ' . $this->table_row_parameters;
             if ($contents[$i]['params']) $tableBox_string .= ' ' . $contents[$i]['params'];
             $tableBox_string .= '>' . "\n";              
           }

 

Hope that helps

Link to comment
Share on other sites

Heres my Product Listing settings in admin as I remembered that this will also effect the way it's displayed.

 

Display Product Image                                                    1   

Display Product Manufaturer Name                                    0

Display Product Model                                                          2

Display Product Name                                                          3

Display Product Price                                                            4

Display Product Quantity                                                  0

Display Product Weight                                                          0

Display Buy Now column                                                        5

Display Category/Manufacturer Filter (0=disable; 1=enable)  0

Location of Prev/Next Navigation Bar (1-top, 2-bottom, 3-both)  3

Display Product Info                                                            6

Link to comment
Share on other sites

***Duff Posting Above DUH***

Hi Stevo,

 

Use a compare programme and compare my product_listing.php that I posted above with yours and see if theres any differences. then do the change to catalog/includes/classes/boxes.php that I mentioned. Then just go into admin and make the changes to the product listing, have a look at my settings above, that sets the order the info is displayed.

 

You can then edit your style sheet and find the line that starts

TR.accountHistory-odd

 

remove

TR.productListing-odd,

 

do the same for

TR.accountHistory-even

and remove

TR.productListing-even,

 

add a new class below the

 background: #f8f8f9;
}

 

enter these two classes

 

TR.productListing-odd {
background: #FFFFFF;
border-color: #9D9D9D;
 border-style: solid;
 border-width: 1px;
}

TR.productListing-even {
background: #f8f8f9;
 border-color: #9D9D9D;
 border-style: solid;
 border-width: 1px;
}

 

This will define the different products more by changing the backgrounds to them slightly.

 

I havn't got the border to work yet, maybe if you do you can post here and let me know how you did it, Also I'm stuck on getting the info to span only 3 columns and not the 4 that it's currently doing, as I don't want it to go below the buy now button, I want the buy now to span 2 rows.

 

Hey Rochdalemark,  I noticed that you managed to get the discription under the name,  Im stuggling to do this. How did you end up doing it! ?!?!?!?

 

Steve

Edited by Rochdalemark
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...