Zen Cart Logo
Forums / Templates, Stylesheets, Page Layout / adding description to new or featured products

adding description to new or featured products

Views: 11,742

Results 1 to 20 of 30
25 Jun 2007, 3:28 PM
#1
winky3d avatar

winky3d

New Zenner

Join Date:
Jun 2007
Posts:
44
Plugin Contributions:
0

adding description to new or featured products

Has anyone been able to add product descriptions to new or featured products?

Both new and featured pull from a db table that doesn't include a description.

Note: It would seem logical that tpl_modules_whats_new.php could be overwritten by tpl_products_new_default.php (which includes descriptions), BUT that does not work for the front page - it can't find the products.

25 Jun 2007, 4:39 PM
#2
winky3d avatar

winky3d

New Zenner

Join Date:
Jun 2007
Posts:
44
Plugin Contributions:
0

Re: adding description to new or featured products

More info...

In modules/featured_products.php, there is this line:

left join " . TABLE_PRODUCTS_DESCRIPTION . " pd on p.products_id = pd.products_id), " .

So I think it's pulling from the table that holds product descriptions.

But how do I add it to the 'text' => etc ?
I tried adding: $featured_products->fields['products_description']
but nothing appears.

25 Jun 2007, 4:51 PM
#3
winky3d avatar

winky3d

New Zenner

Join Date:
Jun 2007
Posts:
44
Plugin Contributions:
0

Re: adding description to new or featured products

Solution add pd.products_description to the query, like so:

$featured_products_query = "select distinct p.products_id, p.products_image, pd.products_name, pd.products_description

14 Jul 2007, 2:07 AM
#4
magneteye avatar

magneteye

Zen Follower

Join Date:
Mar 2007
Location:
Portland, OR
Posts:
163
Plugin Contributions:
0

Re: adding description to new or featured products

I am trying to do this too, can you give me a little more detail?

Thanks!

here's what i have...

if ( (!isset($featured_products_category_id)) || ($featured_products_category_id == '0') ) {
  $featured_products_query = "select distinct p.products_id, p.products_image, pd.products_name, pd.products_description
                           from (" . TABLE_PRODUCTS . " p
                           left join " . TABLE_FEATURED . " f on p.products_id = f.products_id
                           left join " . TABLE_PRODUCTS_DESCRIPTION . " pd on p.products_id = pd.products_id )
                           where p.products_id = f.products_id and p.products_id = pd.products_id and p.products_status = 1 and f.status = 1 and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'";
} else {
  $featured_products_query = "select distinct p.products_id, p.products_image, pd.products_name, pd.products_description
                           from (" . TABLE_PRODUCTS . " p
                           left join " . TABLE_FEATURED . " f on p.products_id = f.products_id
                           left join " . TABLE_PRODUCTS_DESCRIPTION . " pd on p.products_id = pd.products_id), " .
  TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " .
  TABLE_CATEGORIES . " c
                           where p.products_id = p2c.products_id
                           and p2c.categories_id = c.categories_id
                           and c.parent_id = '" . (int)$featured_products_category_id . "'
                           and p.products_id = f.products_id and p.products_id = pd.products_id and p.products_status = 1 and f.status = 1 and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'";

}
14 Jul 2007, 2:22 PM
#5
winky3d avatar

winky3d

New Zenner

Join Date:
Jun 2007
Posts:
44
Plugin Contributions:
0

Re: adding description to new or featured products

It looks like you are pulling the products_description from the database, so now you need to display it... ?

This helped me a lot.
http://www.kirkhamsystems.com/zencart_layout_changes
I think what you want is in the second code box in that article.

15 Jul 2007, 5:01 AM
#6
magneteye avatar

magneteye

Zen Follower

Join Date:
Mar 2007
Location:
Portland, OR
Posts:
163
Plugin Contributions:
0

Re: adding description to new or featured products

winky3d:

It looks like you are pulling the products_description from the database, so now you need to display it... ?

This helped me a lot.
http://www.kirkhamsystems.com/zencart_layout_changes
I think what you want is in the second code box in that article.

yes, its not displaying. look at my cart. no description for the featured product (daily spectacular).

2 Aug 2007, 3:01 AM
#7
cocoon avatar

cocoon

New Zenner

Join Date:
Aug 2007
Posts:
9
Plugin Contributions:
0

Re: adding description to new or featured products

Ok thanks for the tip i was half way (the other half!)

Here is the solution after adding the sql query you need to add the line

$featured_products->fields['products_description']
``` where you want the description to show.

This is my file for your perusal.

Hope it helps, seems to be working for me.

Oh and strip out all those nasty <br /> tags and wrap the price, name etc in tags so you can control them, dont know why they still keep those nasty breaks  in zen cart!

```php
<?php
/**
 * featured_products module - prepares content for display
 *
 * @package modules
 * @copyright Copyright 2003-2006 Zen Cart Development Team
 * @copyright Portions Copyright 2003 osCommerce
 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
 * @version $Id: featured_products.php 4629 2006-09-28 15:29:18Z ajeh $
 */
if (!defined('IS_ADMIN_FLAG')) {
  die('Illegal Access');
}
if ( (!isset($new_products_category_id)) || ($new_products_category_id == '0') ) {
  $featured_products_query = "select distinct p.products_id, p.products_image, pd.products_name, pd.products_description
                           from (" . TABLE_PRODUCTS . " p
                           left join " . TABLE_FEATURED . " f on p.products_id = f.products_id
                           left join " . TABLE_PRODUCTS_DESCRIPTION . " pd on p.products_id = pd.products_id )
                           where p.products_id = f.products_id and p.products_id = pd.products_id and p.products_status = 1 and f.status = 1 and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'";
} else {
  $featured_products_query = "select distinct p.products_id, p.products_image, pd.products_name
                           from (" . TABLE_PRODUCTS . " p
                           left join " . TABLE_FEATURED . " f on p.products_id = f.products_id
                           left join " . TABLE_PRODUCTS_DESCRIPTION . " pd on p.products_id = pd.products_id), " .
  TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " .
  TABLE_CATEGORIES . " c
                           where p.products_id = p2c.products_id
                           and p2c.categories_id = c.categories_id
                           and c.parent_id = '" . (int)$new_products_category_id . "'
                           and p.products_id = f.products_id and p.products_id = pd.products_id and p.products_status = 1 and f.status = 1 and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'";

}
$featured_products = $db->ExecuteRandomMulti($featured_products_query, MAX_DISPLAY_SEARCH_RESULTS_FEATURED);

$row = 0;
$col = 0;
$list_box_contents = array();
$title = '';

$num_products_count = $featured_products->RecordCount();

// show only when 1 or more
if ($num_products_count > 0) {
  if ($num_products_count < SHOW_PRODUCT_INFO_COLUMNS_FEATURED_PRODUCTS || SHOW_PRODUCT_INFO_COLUMNS_FEATURED_PRODUCTS == 0) {
    $col_width = floor(100/$num_products_count);
  } else {
    $col_width = floor(100/SHOW_PRODUCT_INFO_COLUMNS_FEATURED_PRODUCTS);
  }
  while (!$featured_products->EOF) {

    $products_price = zen_get_products_display_price($featured_products->fields['products_id']);

    $list_box_contents[$row][$col] = array('params' =>'class="centerBoxContentsFeatured centeredContent back"' . ' ' . 'style="width:' . $col_width . '%;"',
    'text' => (($featured_products->fields['products_image'] == '' and PRODUCTS_IMAGE_NO_IMAGE_STATUS == 0) ? '' : '<a href="' . zen_href_link(zen_get_info_page($featured_products->fields['products_id']), 'products_id=' . $featured_products->fields['products_id']) . '">' . zen_image(DIR_WS_IMAGES . $featured_products->fields['products_image'], $featured_products->fields['products_name'], IMAGE_FEATURED_PRODUCTS_LISTING_WIDTH, IMAGE_FEATURED_PRODUCTS_LISTING_HEIGHT) . '</a><br />') . '<a href="' . zen_href_link(zen_get_info_page($featured_products->fields['products_id']), 'products_id=' . $featured_products->fields['products_id']) . '">' . $featured_products->fields['products_name'] . '</a><br />' . $products_price . $featured_products->fields['products_description'] );

    $col ++;
    if ($col > (SHOW_PRODUCT_INFO_COLUMNS_FEATURED_PRODUCTS - 1)) {
      $col = 0;
      $row ++;
    }
    $featured_products->MoveNextRandom();
  }

  if ($featured_products->RecordCount() > 0) {
    if (isset($new_products_category_id) && $new_products_category_id !=0) {
      $category_title = zen_get_categories_name((int)$new_products_category_id);
      $title = '<h2 class="centerBoxHeading">' . TABLE_HEADING_FEATURED_PRODUCTS . ($category_title != '' ? ' - ' . $category_title : '') . '</h2>';
    } else {
      $title = '<h2 class="centerBoxHeading">' . TABLE_HEADING_FEATURED_PRODUCTS . '</h2>';
    }
    $zc_show_featured = true;
  }
}
?>
2 Aug 2007, 3:07 AM
#8
cocoon avatar

cocoon

New Zenner

Join Date:
Aug 2007
Posts:
9
Plugin Contributions:
0

Re: adding description to new or featured products

Oh does anyone know how to limit the characters output from the description!!?!?

It would be awesome to be able to limit it to a certain number of characters.

2 Aug 2007, 3:43 AM
#9
magneteye avatar

magneteye

Zen Follower

Join Date:
Mar 2007
Location:
Portland, OR
Posts:
163
Plugin Contributions:
0

Re: adding description to new or featured products

Thanks! Finally after 2 months I got it to work. You rock!

3 Aug 2007, 6:17 AM
#10
cocoon avatar

cocoon

New Zenner

Join Date:
Aug 2007
Posts:
9
Plugin Contributions:
0

Re: adding description to new or featured products

Ok worked out how to truncate the description too

instead of using this code to get the description

$featured_products->fields['products_description']  

You can add this

zen_trunc_string(zen_clean_html(stripslashes(zen_get_products_description($featured_products->fields['products_id'], $_SESSION['languages_id']))), PRODUCT_LIST_DESCRIPTION)

And it will truncate the description, probably to the same amount of characters set in the product listing description admin setting.

Not sure on that as yet but it works.

4 Sep 2007, 1:41 AM
#11
cyberwoolf avatar

cyberwoolf

Zen Follower

Join Date:
Oct 2005
Posts:
97
Plugin Contributions:
0

Re: adding description to new or featured products

Thanks for this! Someone just asked me if they could do this which I didnt think was possible... you are awesome!

16 Dec 2007, 3:53 PM
#12
nimbuz avatar

nimbuz

Zen Follower

Join Date:
Oct 2007
Posts:
291
Plugin Contributions:
0

Re: adding description to new or featured products

I used for featured products successfully. Can this also be used for cross-sell products?

What would the code look like?

Thanks

27 Dec 2007, 7:13 PM
#13
themusician avatar

themusician

New Zenner

Join Date:
Jun 2007
Posts:
64
Plugin Contributions:
0

Re: adding description to new or featured products

cocoon:

Ok worked out how to truncate the description too

instead of using this code to get the description

$featured_products->fields['products_description']

>  
> You can add this
>  
> ```php
zen_trunc_string(zen_clean_html(stripslashes(zen_get_products_description($featured_products->fields['products_id'], $_SESSION['languages_id']))), PRODUCT_LIST_DESCRIPTION)

where do I place this different code? I have been playing around with it but can not get it to work with the truncation code.

Thanks for the insight.

6 Feb 2008, 3:51 AM
#14
gearstudios avatar

gearstudios

New Zenner

Join Date:
Sep 2005
Posts:
88
Plugin Contributions:
0

Re: adding description to new or featured products

I couldn't get this to work.

zen_trunc_string(zen_clean_html(stripslashes(zen_get_products_description($featured_products->fields['products_id'], $_SESSION['languages_id']))), PRODUCT_LIST_DESCRIPTION)

So I did this and it worked!!! Hooray! :clap:

stripslashes(zen_trunc_string(zen_clean_html($featured_products->fields['products_description'])))
3 Apr 2008, 12:08 PM
#15
helexia23 avatar

helexia23

New Zenner

Join Date:
Mar 2008
Posts:
15
Plugin Contributions:
0

Re: adding description to new or featured products

GearStudios:

I couldn't get this to work.

zen_trunc_string(zen_clean_html(stripslashes(zen_get_products_description($featured_products->fields['products_id'], $_SESSION['languages_id']))), PRODUCT_LIST_DESCRIPTION)

> 
> So I did this and it worked!!! Hooray! :clap:
> 
> ```
stripslashes(zen_trunc_string(zen_clean_html($featured_products->fields['products_description'])))

Where exactly do you put this code in featured_products.php? As you can see https://www.killerlube.com/store I definately need to truncate that text...

3 Apr 2008, 12:19 PM
#16
helexia23 avatar

helexia23

New Zenner

Join Date:
Mar 2008
Posts:
15
Plugin Contributions:
0

Re: adding description to new or featured products

I can't seem to edit my last post. I figured out how to truncate the description but if you look at https://www.killerlube.com/store it looks all jumbled. Any way I can pretty that up?

28 Jul 2008, 6:47 PM
#17
bumba000 avatar

bumba000

Totally Zenned

Join Date:
Feb 2007
Location:
Pennsylvania
Posts:
856
Plugin Contributions:
0

Re: adding description to new or featured products

Okay. In addition to the previous replies in ZC 1.3.8a. . .

I have wrapped div tags around all elements in the specials_index, featured_products and new_products.php so that I can style them how I like and move them all into place.

New products

'<div class="listBoxProductsDescription">'.zen_trunc_string(zen_clean_html(stripslashes(zen_get_products_description($new_products->fields['products_id'], $_SESSION['languages_id']))), PRODUCT_LIST_DESCRIPTION) .'</div>'
```Specials products

.'<div class="listBoxProductsDescription">' zen_trunc_string(zen_clean_html(stripslashes(zen_get_products_description($specials_index->fields['products_id'], $_SESSION['languages_id']))), PRODUCT_LIST_DESCRIPTION) '</div>'.

.'<div class="listBoxProductsDescription">'.zen_trunc_string(zen_clean_html(stripslashes(zen_get_products_description($featured_products->fields['products_id'], $_SESSION['languages_id']))), PRODUCT_LIST_DESCRIPTION) '</div>'.


Example:

($new_products->fields['products_id']
($specials_index->fields['products_id']
($featured_products->fields['products_id']

11 Sep 2008, 12:14 PM
#18
fareed avatar

fareed

New Zenner

Join Date:
Sep 2008
Location:
Pakistan
Posts:
7
Plugin Contributions:
0

Re: adding description to new or featured products

Dear,
Is there any way to increase the description of featured products listed on main page. My reference page is https://www.rabiabooks.com, this is truncating the description after 25 characters buy I want to increase the limit upto 256 characters.

Please help...

Regards,
Fareed

13 Sep 2008, 3:53 PM
#19
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: adding description to new or featured products

If you are referring to the Product Listing and the description length, there is a setting in the Configuration ... Product Listing ...

Display Product Description
Do you want to display the Product Description?

0= OFF
150= Suggested Length, or enter the maximum number of characters to display

15 Sep 2008, 7:31 AM
#20
fareed avatar

fareed

New Zenner

Join Date:
Sep 2008
Location:
Pakistan
Posts:
7
Plugin Contributions:
0

Re: adding description to new or featured products

Dear,
I want to increase the length of short description for featured products. You may have a look at previously referred page.

Regards,
Fareed