Forums / General Questions / Product Listing "Display Product Listing" length from parsing?

Product Listing "Display Product Listing" length from parsing?

Locked

Started by monsunemoon on 12 Jan 2010, 12:52 AM · Views: 1,729

Results 1 to 5 of 5
This thread is locked. New replies are disabled.
12 Jan 2010, 12:52 AM
#1
monsunemoon avatar

monsunemoon

New Zenner

Join Date:
Jan 2010
Posts:
27
Plugin Contributions:
0

Product Listing "Display Product Listing" length from parsing?

This is my first post :D. I have set up a store, and I have my products displayed nicely in a nice grid (thanks to "Column Layout Grid for Product Listing"). However, I would like for the description in the product listing to only display the first sentence of each description.

I know I can set the length of the description in Admin > configuration > Product Listing > Display Product Description. However all of my products do not have the same length for the first sentence in their description.

My questions are:

  1. Can I put some symbol (HTML or PHP etc) in the description to make it stop reading into the product listing description at a given point (and continue to read in the product details window)?

or

  1. Is there a way of parsing the product description to stop at the first fullstop (or period if your american)?

or

  1. Can I split the product description somehow so it can be read in the product details screen with all of the information, but only the first sentence in the product list screen?

Thanks in advance.:clap:

12 Jan 2010, 2:29 AM
#2
gmrm avatar

gmrm

Zen Follower

Join Date:
Apr 2009
Location:
Oxford UK
Posts:
192
Plugin Contributions:
0

Re: Product Listing "Display Product Listing" length from parsing?

Try product description as 0. I did this on 1 of my stores and it only displayed the product title

12 Jan 2010, 5:36 AM
#3
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,874
Plugin Contributions:
8

Re: Product Listing "Display Product Listing" length from parsing?

Yes, you first have to enable HTML in the product listing. Search for zen_clean_html for directions, and mind the cautions attending that move.

Then you can put a <div class="listingDescHide"> or the like around the part you don't want showing in the listing, and add a stylesheet rule
#productListing .listingDescHide {display: none;}

12 Jan 2010, 8:15 PM
#4
monsunemoon avatar

monsunemoon

New Zenner

Join Date:
Jan 2010
Posts:
27
Plugin Contributions:
0

Re: Product Listing "Display Product Listing" length from parsing?

Thanks Gelnn. I read another thread you posted this on (http://www.zen-cart.com/forum/showthread.php?t=77271). Folowing your instructions, I modified includes/modules/my template/product_listing.php as you instructed:

I Changed

        $lc_align = '';
        if (isset($_GET['manufacturers_id'])) {
          $lc_text = '<h3 class="itemTitle"><a href="' . zen_href_link(zen_get_info_page($listing->fields['products_id']), 'cPath=' . (($_GET['manufacturers_id'] > 0 and $_GET['filter_id']) > 0 ?  zen_get_generated_category_path_rev($_GET['filter_id']) : ($_GET['cPath'] > 0 ? zen_get_generated_category_path_rev($_GET['cPath']) : zen_get_generated_category_path_rev($listing->fields['master_categories_id']))) . '&products_id=' . $listing->fields['products_id']) . '">' . $listing->fields['products_name'] . '</a></h3><div class="listingDescription">' . zen_trunc_string(zen_clean_html(stripslashes(zen_get_products_description($listing->fields['products_id'], $_SESSION['languages_id']))), PRODUCT_LIST_DESCRIPTION) . '</div>' ;
        } else {
          $lc_text = '<h3 class="itemTitle"><a href="' . zen_href_link(zen_get_info_page($listing->fields['products_id']), 'cPath=' . (($_GET['manufacturers_id'] > 0 and $_GET['filter_id']) > 0 ?  zen_get_generated_category_path_rev($_GET['filter_id']) : ($_GET['cPath'] > 0 ? zen_get_generated_category_path_rev($_GET['cPath']) : zen_get_generated_category_path_rev($listing->fields['master_categories_id']))) . '&products_id=' . $listing->fields['products_id']) . '">' . $listing->fields['products_name'] . '</a></h3><div class="listingDescription">' . zen_trunc_string(zen_clean_html(stripslashes(zen_get_products_description($listing->fields['products_id'], $_SESSION['languages_id']))), PRODUCT_LIST_DESCRIPTION) . '</div>';
        }
        break;

to:

        case 'PRODUCT_LIST_NAME':
        $lc_align = '';
        if (isset($_GET['manufacturers_id'])) {
          $lc_text = '<h3 class="itemTitle"><a href="' . zen_href_link(zen_get_info_page($listing->fields['products_id']), 'products_id=' . $listing->fields['products_id']) . '">' . $listing->fields['products_name'] . '</a></h3><div class="listingDescription">' . str_replace(strstr(zen_clean_html(stripslashes(zen_get_products_description($listing->fields['products_id'], $_SESSION['languages_id']))),"*more*"),"",(zen_clean_html(stripslashes(zen_get_products_description($listing->fields['products_id'], $_SESSION['languages_id']))))) . '</div>' ;
        } else {
          $lc_text = '<h3 class="itemTitle"><a href="' . zen_href_link(zen_get_info_page($listing->fields['products_id']), ($_GET['cPath'] > 0 ? 'cPath=' . $_GET['cPath'] . '&' : '') . 'products_id=' . $listing->fields['products_id']) . '">' . $listing->fields['products_name'] . '</a></h3><div class="listingDescription">' . str_replace(strstr(zen_clean_html(stripslashes(zen_get_products_description($listing->fields['products_id'], $_SESSION['languages_id']))),"*more*"),"",(zen_clean_html(stripslashes(zen_get_products_description($listing->fields['products_id'], $_SESSION['languages_id']))))) . '</div>';
        }
        break;

This worked in shortening the drescription on the product list page to where I place more in the product description.

I have also added this to my stylesheet:

#productListing .listingDescHide
{
	display: none; 
} 

However when I write my description:

This is some text.

<div class="listingDescHide"; display: none; >*more*</div> This is a test to see if this code shows up.

In the product details page, the description still has the more visible, and looks like this:

This is some text.
more
This is a test to see if this code shows up.

I cant seem to get rid of the more from the description on the product information page. any ideas? :blink:

Thanks again

12 Jan 2010, 8:48 PM
#5
monsunemoon avatar

monsunemoon

New Zenner

Join Date:
Jan 2010
Posts:
27
Plugin Contributions:
0

Re: Product Listing "Display Product Listing" length from parsing?

It's alright I found how to do it in your other thread:

http://www.zen-cart.com/forum/showthread.php?t=77271

Thanks a lot, that was really useful