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 21 to 30 of 30
16 Sep 2008, 5:06 AM
#21
ajeh avatar

ajeh

Oba-san

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

adding description to new or featured products

Did you perhaps peek in the Configuration ... Featured Listing ...

Display Product Description
How many characters do you want to display of the Product Description?

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

Looks a lot like the other one but each Listing has its own settings for customizations ... :smile:

9 Nov 2008, 6:55 AM
#22
member avatar

member

Zen Follower

Join Date:
Dec 2004
Posts:
102
Plugin Contributions:
0

Re: adding description to new or featured products

I used this for featured and specials by following post 3 and post 7.

winky3d:

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

cocoon:

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']


I can't get new products to do the same thing.  I have product short descriptions installed and the includes/modules/new_products.php
has been modified.  I tried hiding it and editing the default file.  It just won't work.  

Can anyone suggest what about the products short description could be hindering me from replacing the product name with the product description?  I changed the right thing, but it won't work, the add on has caused some type of issue.

Thank you for any suggestions.
21 Nov 2008, 3:25 AM
#23
exoticcorpse avatar

exoticcorpse

New Zenner

Join Date:
Jan 2008
Posts:
35
Plugin Contributions:
0

Re: adding description to new or featured products

fareed:

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

To manually change the description length to something other than the limit set for all product listing, change the following code provided earlier in the thread from:

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

to

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

In this case 250 is the character limit, but can be set to your required length.

25 Dec 2008, 1:12 PM
#24
malhyp avatar

malhyp

New Zenner

Join Date:
Dec 2008
Posts:
28
Plugin Contributions:
0

Re: adding description to new or featured products

Hi there, sorry im not having much luck with this.

<?php
/**
 * featured_products module - prepares content for display
 *
 * @package modules
 * @copyright Copyright 2003-2007 Zen Cart Development Team
 * @copyright Portions Copyright 2003 osCommerce
 * @version $Id: featured_products.php 6424 2007-05-31 05:59:21Z ajeh $
 */
if (!defined('IS_ADMIN_FLAG')) {
  die('Illegal Access');
}

// initialize vars
$categories_products_id_list = '';
$list_of_products = '';
$featured_products_query = '';
$display_limit = '';

if ( (($manufacturers_id > 0 && $_GET['filter_id'] == 0) || $_GET['music_genre_id'] > 0 || $_GET['record_company_id'] > 0) || (!isset($new_products_category_id) || $new_products_category_id == '0') ) {
  $featured_products_query = "select distinct p.products_id, p.products_image, pd.products_name, p.master_categories_id, 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 {
  // get all products and cPaths in this subcat tree
  $productsInCategory = zen_get_categories_products_list( (($manufacturers_id > 0 && $_GET['filter_id'] > 0) ? zen_get_generated_category_path_rev($_GET['filter_id']) : $cPath), false, true, 0, $display_limit);

  if (is_array($productsInCategory) && sizeof($productsInCategory) > 0) {
    // build products-list string to insert into SQL query
    foreach($productsInCategory as $key => $value) {
      $list_of_products .= $key . ', ';
    }
    $list_of_products = substr($list_of_products, 0, -2); // remove trailing comma
    $featured_products_query = "select distinct p.products_id, p.products_image, pd.products_name, p.master_categories_id, 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'] . "'
                                and p.products_id in (" . $list_of_products . ")";
  }
}
if ($featured_products_query != '') $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_query == '') ? 0 : $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']);
    $products_######## = '<a href="' . zen_href_link(zen_get_info_page($new_products->fields['products_id']), 'products_id=' . $new_products->fields['products_id']) . '">' . zen_image_button(BUTTON_IMAGE_GOTO_PROD_DETAILS, BUTTON_GOTO_PROD_DETAILS_ALT) . '</a>';  //hsyong

    if (!isset($productsInCategory[$featured_products->fields['products_id']])) $productsInCategory[$featured_products->fields['products_id']] = zen_get_generated_category_path_rev($featured_products->fields['master_categories_id']);

    $list_box_contents[$row][$col] = array('params' =>'class="centerBoxContentsFeatured1 centeredContent1 back"' . ' ' . 'style="width:' . $col_width . '%;"',
    'text' => (($featured_products->fields['products_image'] == '' and PRODUCTS_IMAGE_NO_IMAGE_STATUS == 0) ? '' : '<div class="product_img_title"><a href="' . zen_href_link(zen_get_info_page($featured_products->fields['products_id']), 'cPath=' . $productsInCategory[$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  class="producttitle" href="' . zen_href_link(zen_get_info_page($featured_products->fields['products_id']), 'cPath=' . $productsInCategory[$featured_products->fields['products_id']] . '&products_id=' . $featured_products->fields['products_id']) . '">' . $featured_products->fields['products_name'] . '</a></div><span class="text_price">' . $products_price . '</span><br />' . $products_########);
  //'text' => (($new_products->fields['products_image'] == '' and PRODUCTS_IMAGE_NO_IMAGE_STATUS == 0) ? '' : '<div class="product_img_title"><a href="' . zen_href_link(zen_get_info_page($new_products->fields['products_id']), 'cPath=' . $productsInCategory[$new_products->fields['products_id']] . '&products_id=' . $new_products->fields['products_id']) . '">' . zen_image(DIR_WS_IMAGES . $new_products->fields['products_image'], $new_products->fields['products_name'], IMAGE_PRODUCT_NEW_WIDTH, IMAGE_PRODUCT_NEW_HEIGHT) . '</a><br />') . '<a class="producttitle" href="' . zen_href_link(zen_get_info_page($new_products->fields['products_id']), 'cPath=' . $productsInCategory[$new_products->fields['products_id']] . '&products_id=' . $new_products->fields['products_id']) . '">' . $new_products->fields['products_name'] . '</a></div><br /><span class="text_price">' . $products_price . '</span><br />' . $products_########);  //hsyong

    $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;
  }
}
?>

I have inserted the "pd.products_description" in the 2 spots where i could see it going but dont know where I should be adding "'products_description'" to.

Can anyone help?

7 Jan 2009, 2:04 AM
#25
malhyp avatar

malhyp

New Zenner

Join Date:
Dec 2008
Posts:
28
Plugin Contributions:
0

Re: adding description to new or featured products

Hi there, think that im almost there with this.

    'text' => (($featured_products->fields['products_image'] == '' and PRODUCTS_IMAGE_NO_IMAGE_STATUS == 0) ? '' : '<div class="product_img_title"><a href="' . zen_href_link(zen_get_info_page($featured_products->fields['products_id']), 'cPath=' . $productsInCategory[$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 class="producttitle" href="' . zen_href_link(zen_get_info_page($featured_products->fields['products_id']), 'cPath=' . $productsInCategory[$featured_products->fields['products_id']] . '&products_id=' . $featured_products->fields['products_id']) . '">' . $featured_products->fields['products_name'] . '</a></div><span class="text_price">' . $products_price .  '</span><br />' . [B]$featured_products->fields['products_description']).[/B] $products_########);

I have added the $featured_products->fields['products_description']) script but for some reason when I apply it the featured product disappears. Any suggestions?

22 May 2009, 10:31 PM
#26
brewster8216 avatar

brewster8216

New Zenner

Join Date:
May 2009
Posts:
5
Plugin Contributions:
0

Re: adding description to new or featured products

I'm having the same problem that an earlier responder mentioned:

This seems to works for featured products but NOT for new products, i.e., new_products.php.

Here is the relevant code:

I've added pd.products_description to the query:

$new_products_query = "select distinct p.products_id, p.products_image, pd.products_name, pd.products_description,
p.products_date_added, p.products_price, p.products_type, p.master_categories_id
from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd
where p.products_id = pd.products_id
and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'
and p.products_id in (" . $list_of_products . ")";
}
}

I've assigned a variable:

$products_description = $new_products->fields['products_description'];

I've added the variable to the HTML:

$list_box_contents[$row][$col] = array('params' => 'class="centerBoxContentsNew centeredContent back"' . ' ' . 'style="width:' . $col_width . '%;"',
'text' => (($new_products->fields['products_image'] == '' and PRODUCTS_IMAGE_NO_IMAGE_STATUS == 0) ? '' : '<a href="' . zen_href_link(zen_get_info_page($new_products->fields['products_id']), 'cPath=' . $productsInCategory[$new_products->fields['products_id']] . '&products_id=' . $new_products->fields['products_id']) . '">' . zen_image(DIR_WS_IMAGES . $new_products->fields['products_image'], $new_products->fields['products_name'], IMAGE_PRODUCT_NEW_WIDTH, IMAGE_PRODUCT_NEW_HEIGHT) . '</a><br />') . '<a href="' . zen_href_link(zen_get_info_page($new_products->fields['products_id']), 'cPath=' . $productsInCategory[$new_products->fields['products_id']] . '&products_id=' . $new_products->fields['products_id']) . '">' . $new_products->fields['products_name'] . '</a><br /> . **$products_description** . $products_price . '**<br>skdk'**);

I've added a piece of garbage text skdk to see if that prints, and it does. But you don't see the product description. I've also tested $products_description with an if blank statement, and it returns that the variable is blank.

I suspect there is some code here that is automatically chopping off this addition. Any help appreciated.

23 May 2009, 12:59 AM
#27
brewster8216 avatar

brewster8216

New Zenner

Join Date:
May 2009
Posts:
5
Plugin Contributions:
0

Re: adding description to new or featured products

Well, I found the problem when I stepped away for awhile, but this is still good to know. There are 2 SQL queries in this script, and I only added pd.products_description to one of them.

23 May 2009, 7:32 PM
#28
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

Thanks for the update ... always a help to others ... :smile:

20 Aug 2009, 3:46 PM
#29
maineiac13 avatar

maineiac13

New Zenner

Join Date:
Sep 2008
Posts:
98
Plugin Contributions:
0

Re: adding description to new or featured products

Glad I found this thread as I used it for adding descriptions to new products as shown on the home page.

I ended up using the code posted by brewster8216 in post #26 (making sure that I added the code to both sql queries).

I modified the variable in that post to truncate the description...using the code posted by GearStudios in post #14....changing it of course to refer to new products rather than featured products. In my case, the variable now reads:

$products_description = stripslashes(zen_trunc_string(zen_clean_html($new_products->fields['products_description'])));

I also made one change in the HTML code by adding a line break after the description and before the price so that the price would show on a new line.

Thanks to all the people that have participated in this thread.:smile:

15 Apr 2011, 3:00 PM
#30
dome90uk avatar

dome90uk

New Zenner

Join Date:
Nov 2009
Posts:
16
Plugin Contributions:
0

Re: adding description to new or featured products

Hi,

I could not get the examples in this thread to work for me but found a solution that worked on a free template.

This worked for me ...

  1. add the pd.products_description to the two SQL Query as detailed in brewster8216's post #26.
  2. I did not declare a variable
  3. I inserted the code below into the same place ( html output ) brewster8216 placed his variable.
 . zen_clean_html(zen_trunc_string($new_products->fields['products_description'], 200)) .