Jump to content


Corporate Sponsors


Latest News: (loading..)

- - - - -

Add Mini Descriptions to Product Listings


24 replies to this topic

#1 npn2531

  • Community Member
  • 951 posts
  • Real Name:Jase
  • Gender:Not Telling

Posted 21 December 2009, 21:13

This is a relatively easy way to dress up your category product listings with a mini description in the product name column. It also allows for adding some HTML to customize how it displays.

You can see what it looks like here:

http://www.niora.com/anti-aging-acne-care

On what it looks like on a new install of OSCommerce here:

http://adult-acne-product.com/catalog/index.php?cPath=3_10



1)Create a new field in products_description, I suggest 255 characters long

ALTER TABLE `products_description` ADD `products_minidescp` LONGTEXT NOT NULL


2. Paste the following query into catalog/includes/modules/product_listings.php about line 85-90 (assuming a new install). Be sure to place it below the ' }' and above '$cur_row = sizeof($list_box_contents) - 1;'

//BOF add a mini-description
$pl_id = $listing['products_id'];
$minidescp_query = tep_db_query("select products_id, products_minidescp from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id  = '" .$pl_id. "'");
    $minidescp = tep_db_fetch_array($minidescp_query);
    $pl_minidescp = '<p>'.$minidescp['products_minidescp'].'</p>';
//EOF add a mini-description


3. A few lines below that add the variable $pl_minidescp at the end of this line:

This line:
 $lc_text = '&nbsp;<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing['products_id']) . '">' . $listing['products_name'] . '</a>';

is changed to this:

$lc_text = '&nbsp;<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing['products_id']) . '">' . $listing['products_name'] . '</a><br/>'.$pl_minidescp;

4. Manually enter your mini-descriptions into products_descriptions.products_minidescp
( A proper user interface in admin/categories.php might look it like a contribution )

Edited by npn2531, 21 December 2009, 21:23.


#2 DunWeb

  • Community Sponsor
  • 10,455 posts
  • Real Name:Chris Dunn
  • Gender:Male
  • Location:Tecumseh, Ontario, Canada N8N 1X8

Posted 21 December 2009, 21:24

George,


I believe the full contribution can be found here :

http://addons.oscommerce.com/info/3123



Chris
:|: Was this post helpful ? Click the LIKE THIS button :|:

:|: Click Here to learn how I can help you with custom coding, add ons, security and templates :|:

:|: Need an Area Calculator, Pre-Paid Account, Virtual Pin, Auction or Layaway Add on ? Click Here :|:

#3 npn2531

  • Community Member
  • 951 posts
  • Real Name:Jase
  • Gender:Not Telling

Posted 21 December 2009, 21:35

View PostDunWeb, on 21 December 2009, 21:24, said:

George,


I believe the full contribution can be found here :

http://addons.oscommerce.com/info/3123



Chris

Jeebus, and it's been around since 05. It has the user interface, the hard part. This tip here has the advantage of being nothing more than a short bit of code added to one file and adding one field to one table, but you are going to have to be fine with adding data directly to the database to use this.

#4 DunWeb

  • Community Sponsor
  • 10,455 posts
  • Real Name:Chris Dunn
  • Gender:Male
  • Location:Tecumseh, Ontario, Canada N8N 1X8

Posted 21 December 2009, 21:43

Well George,

It is a good addition...........unfortunately someone thought of it 4 yrs ago. But, I am sure you will come up with something nobody else has sooner or later. Just joking with you.

Tip: Check the add-ons section before starting a new contribution.




Chris
:|: Was this post helpful ? Click the LIKE THIS button :|:

:|: Click Here to learn how I can help you with custom coding, add ons, security and templates :|:

:|: Need an Area Calculator, Pre-Paid Account, Virtual Pin, Auction or Layaway Add on ? Click Here :|:

#5 npn2531

  • Community Member
  • 951 posts
  • Real Name:Jase
  • Gender:Not Telling

Posted 21 December 2009, 21:52

I had no notion of making a contribution out of this. It always fun to think about making a contribution, but I took one look at admin/categories.php and that notion went quickly by the wayside.

#6 spooks

  • Community Member
  • 7,017 posts
  • Real Name:Sam
  • Gender:Male
  • Location:UK

Posted 30 December 2009, 13:47

View Postnpn2531, on 21 December 2009, 21:52, said:

I had no notion of making a contribution out of this. It always fun to think about making a contribution, but I took one look at admin/categories.php and that notion went quickly by the wayside.


But categories.php is a nice little file easy to mod!! [img]http://forums.oscommerce.com/public/style_emoticons/default/cool.gif[/img]


I kid!!, I admit I cannot understand why it was made as it is, clearly it started out to edit categories, but then does products too, I think the two functions would be better done in seperate files. [img]http://forums.oscommerce.com/public/style_emoticons/default/huh.gif[/img]


PS take care when adding queries in the listing, on a large shop or slow server too many queries can become an issue, its better to get the data for all displayed product with one query, instead of one query for every product. [img]http://forums.oscommerce.com/public/style_emoticons/default/wink.gif[/img]
Sam

Remember, What you think I ment may not be what I thought I ment when I said it.

Contributions:


Auto Backup your Database, Easy way

Multi Images with Fancy Pop-ups, Easy way

Products in columns with multi buy etc etc

Disable any Category or Product, Easy way

Secure & Improve your account pages et al.

#7 npn2531

  • Community Member
  • 951 posts
  • Real Name:Jase
  • Gender:Not Telling

Posted 31 December 2009, 03:52

View Postspooks, on 30 December 2009, 13:47, said:

But categories.php is a nice little file easy to mod!! [img]http://forums.oscommerce.com/public/style_emoticons/default/cool.gif[/img]


I kid!!, I admit I cannot understand why it was made as it is, clearly it started out to edit categories, but then does products too, I think the two functions would be better done in seperate files. [img]http://forums.oscommerce.com/public/style_emoticons/default/huh.gif[/img]


PS take care when adding queries in the listing, on a large shop or slow server too many queries can become an issue, its better to get the data for all displayed product with one query, instead of one query for every product. [img]http://forums.oscommerce.com/public/style_emoticons/default/wink.gif[/img]

Yes, I had to unfold the extra long page extension handles on Adobe Golive just to open categories.php. In regards to adding a new query on the listings page, it did feel redundant to add a new query on products_description as variables for the fields of the products_description table are floating around already. But I didn't find a query in or above product_listings.php I felt comfortable adding the new field products_minidescrip to.

#8 npn2531

  • Community Member
  • 951 posts
  • Real Name:Jase
  • Gender:Not Telling

Posted 07 January 2010, 02:57

Here is how you eliminate the query in product_listing.php, and make an easy way to add a mini-description even easier (the entire process follows):

1)Create a new field in products_description, I suggest 255 characters long, as before

ALTER TABLE `products_description` ADD `products_minidescp` LONGTEXT NOT NULL
Then manually add your product descriptions to the database.

2) on about line 153 in index.php change:

case 'PRODUCT_LIST_NAME':
          $select_column_list .= 'pd.products_name,   ';
          break;
to this:
case 'PRODUCT_LIST_NAME':
          $select_column_list .= 'pd.products_name, pd.products_minidescp,  ';
          break;

(you are adding the phrase ->pd.products_minidescp,)

3) On about line 103 in includes/modules/product_listing.php, change this:
$lc_text = ' <a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing['products_id']) . '">' . $listing['products_name'] . '</a>';

to this:
  $lc_text = '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing['products_id']) . '">' . $listing['products_name'] . '</a><br/>'. $listing['products_minidescp'];

(You are adding-><br/>'. $listing['products_minidescp']; <- to the end of the line.)

You can see it here:
http://www.niora.com/anti-aging-acne-care

or here on a new OSCommerce install:
http://adult-acne-product.com/catalog/index.php?cPath=3_10

Edited by npn2531, 07 January 2010, 03:02.


#9 broadstreetbully

  • Community Member
  • 69 posts
  • Real Name:jason

Posted 24 November 2010, 23:07

View Postnpn2531, on 21 December 2009, 21:35, said:

Jeebus, and it's been around since 05. It has the user interface, the hard part. This tip here has the advantage of being nothing more than a short bit of code added to one file and adding one field to one table, but you are going to have to be fine with adding data directly to the database to use this.

either this addon is out of date or written wrong...there's a piece of code that needs to be added onto another piece of code that is not in the file. I checked in the code editor, dreamweaver and coffee cup just to make certain I'm not losing my mind and it definitely is not there.....plus this has to be one of the longest-taking addons to install, not to mention adding to your database...skip this if you know what's good for you....

#10 npn2531

  • Community Member
  • 951 posts
  • Real Name:Jase
  • Gender:Not Telling

Posted 26 November 2010, 20:17

See comment #8 for the correct way to add the mini description in 2.2RC2a.
For 2.3 it is a little different and done like this:

1)Create a new field in products_description, I suggest 255 characters long, as before
ALTER TABLE `products_description` ADD `products_minidescp` LONGTEXT NOT NULL
Then type in your mini descriptions directly into the database.


2) on about line 121 in index.php change:
case 'PRODUCT_LIST_NAME':
          $select_column_list .= 'pd.products_name,   ';
          break;

to this:
case 'PRODUCT_LIST_NAME':
          $select_column_list .= 'pd.products_name, pd.products_minidescp,  ';
          break;

3) finally in includes/modules/product_listing.php, change this:
case 'PRODUCT_LIST_NAME':
            if (isset($HTTP_GET_VARS['manufacturers_id']) && tep_not_null($HTTP_GET_VARS['manufacturers_id'])) {
              $prod_list_contents .= '        <td><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id'] . '&products_id=' . $listing['products_id']) . '">' . $listing['products_name'] . '</a></td>';
            } else {
              $prod_list_contents .= '        <td><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing['products_id']) . '">' . $listing['products_name'] . '</a></td>';
            }
to this:
case 'PRODUCT_LIST_NAME':
            if (isset($HTTP_GET_VARS['manufacturers_id']) && tep_not_null($HTTP_GET_VARS['manufacturers_id'])) {
              $prod_list_contents .= '        <td><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id'] . '&products_id=' . $listing['products_id']) . '">' . $listing['products_name'] . '</a><br/>'. $listing['products_minidescp'].'</td>';
            } else {
              $prod_list_contents .= '        <td><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing['products_id']) . '">' . $listing['products_name'] . '</a><br/>'. $listing['products_minidescp'].'</td>';
            }
Click the demo here to see what this looks like.
http://www.niora.com/css-oscommerce.php

Edited by npn2531, 26 November 2010, 20:30.


#11 StreamMan

  • Community Member
  • 16 posts
  • Real Name:stream

Posted 26 December 2010, 00:22

Hello, Can someone please explane step 1? I'm guessing it as something to to with phpmyAdmin? Thank you very much for the time you spend on explaing this to me.

#12 kymation

  • Community Sponsor
  • 5,661 posts
  • Real Name:Jim Keebaugh
  • Gender:Male
  • Location:Aberdeen WA USA

Posted 26 December 2010, 01:24

Step one has a minor error: longtext is 4 million characters, not 255. For a 255 character data field, use this:

ALTER TABLE `products_description` ADD `products_minidescp` VARCHAR(255) NOT NULL

Yes, you use phpMyAdmin. Just click on the SQL tab and paste that code in, then click Go.

Regards
Jim
My Addons

Banners Box 2.3.1 Support
Categories Accordion Box 2.3.1 Support
Categories Images Box 2.2x 2.3.1 Support
Closest Shipper 2.2x Support
Document Manager 2.2x Support
Generic Box 2.3.1 Support
Get 1 Free 2.2x Support
Include HTML and Text Boxes 2.2x
jQuery Banner Rotator 2.2x 2.3.1 Support
Modular Front Page 2.3.1 Support
Modular SEO Header Tags 2.3.1 Support
More Pics 2.2x Support
MVS 2.2x Support
osC Catalog 2.2x Support
PDF Datasheet 2.3.1 Support
Price Updater 2.2x
Products Specifications 2.2x 2.3.1 Development Version Support Bugs/Suggestions
Request a Review 2.2x - 2.3.1 Support
Similar Products Box 2.2x
Theme Switcher 2.3.1 Support

#13 StreamMan

  • Community Member
  • 16 posts
  • Real Name:stream

Posted 27 December 2010, 01:53

Thank you Jim! I've got it working,

#14 pdcelec

  • Community Member
  • 606 posts
  • Real Name:Paul Clifford
  • Gender:Male
  • Location:UK

Posted 03 January 2011, 22:48

I added it to admin/categories.php, by searching for all occurrences of products_description and adding products_minidescp after it. Then add a new function by copying the tep_get_products_description to tep_get_products_minidescp

#15 npn2531

  • Community Member
  • 951 posts
  • Real Name:Jase
  • Gender:Not Telling

Posted 04 January 2011, 01:58

View Postpdcelec, on 03 January 2011, 22:48, said:

I added it to admin/categories.php, by searching for all occurrences of products_description and adding products_minidescp after it. Then add a new function by copying the tep_get_products_description to tep_get_products_minidescp

That's about the most succinct and clearest instructions I've heard for doing this. Thanks!

#16 Guldstrand

  • Community Member
  • 64 posts
  • Real Name:Guldstrand
  • Gender:Male
  • Location:Sweden

Posted 19 January 2011, 19:17

Am I missing something here? :blink:
I'm running osCommerce 2.3.1, and changed all the files, and added the field in the database.

How is it intended that the new field should be used?
Do you have to fill in the short description somewhere, or will this be retrieved from the original description?

Sorry for any stupid questions.
I am who I am, unfortunately.

#17 npn2531

  • Community Member
  • 951 posts
  • Real Name:Jase
  • Gender:Not Telling

Posted 19 January 2011, 19:22

You have to fill out the short description directly into the database. The new field is empty and does not pull info from anywhere. You can do this if you are familiar with how to use phpMyAdmin.

However, if you would rather fill in the field from the admin, see post #14 above.

#18 Guldstrand

  • Community Member
  • 64 posts
  • Real Name:Guldstrand
  • Gender:Male
  • Location:Sweden

Posted 19 January 2011, 19:28

View Postnpn2531, on 19 January 2011, 19:22, said:

You have to fill out the short description directly into the database. The new field is empty and does not pull info from anywhere. You can do this if you are familiar with how to use phpMyAdmin.

However, if you would rather fill in the field from the admin, see post #14 above.
Now i understand much better.
Many thanks for the explanation and for the quick reply. :D
I am who I am, unfortunately.

#19 14steve14

  • Community Member
  • 2,175 posts
  • Real Name:Steve
  • Gender:Male

Posted 02 February 2011, 12:28

After all thesee posts i have to say this is a step back for oscommerce. What a lot of trouble to go through to get a short description. There is a contribution, that works with 2.3.1 which automatically uses the first 80 characters fron the product descriptions and add that as a short description. No messing with the databse at all, and you only need to add the information once. Simple to use and install. The contribution can be found HERE
REMEMBER BACKUP, BACKUP AND BACKUP
I am not a coder. OSC has a steep learning curve, but in general the program does work. If it doesnt work, the chances are it is something you have done.

#20 Guldstrand

  • Community Member
  • 64 posts
  • Real Name:Guldstrand
  • Gender:Male
  • Location:Sweden

Posted 02 February 2011, 12:33

View Post14steve14, on 02 February 2011, 12:28, said:

After all thesee posts i have to say this is a step back for oscommerce. What a lot of trouble to go through to get a short description. There is a contribution, that works with 2.3.1 which automatically uses the first 80 characters fron the product descriptions and add that as a short description. No messing with the databse at all, and you only need to add the information once. Simple to use and install. The contribution can be found HERE
Good to know! I'll try this instead.
I am who I am, unfortunately.