Zen Cart Logo
Forums / Customization from the Admin / cutting product descriptions manually (for listings)

cutting product descriptions manually (for listings)

Locked

Views: 5,190

Results 1 to 16 of 16
This thread is locked. New replies are disabled.
8 Oct 2007, 11:03 PM
#1
poosk avatar

poosk

Totally Zenned

Join Date:
Mar 2005
Location:
Helsinki
Posts:
477
Plugin Contributions:
0

cutting product descriptions manually (for listings)

Okay there's this super handy function in wordpress which strips blog posts on the frontpage, whenever it runs in to <-- more --> command (or something similar)

Anyway could we make similar thing to zen?

Basic idea is that we'd add manually some command in the description from the admin and it would strip the product description in product listing pages instead of constant number of characters.

is there a better way (aka simpler method to our html illiterate people) to make this happen besides using hidden css class in the listing pages?

9 Oct 2007, 12:19 AM
#2
poosk avatar

poosk

Totally Zenned

Join Date:
Mar 2005
Location:
Helsinki
Posts:
477
Plugin Contributions:
0

Re: cutting product descriptions manually (for listings)

actually somehow the product listing page doesn't display html at all in the product description?!? so even I'd wrap the text I'd want to leave out into a div it won't display the div at all..

any idea how to fix this? I'm using grid (column) mod

9 Oct 2007, 6:58 AM
#3
gjh42 avatar

gjh42

Black Belt

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

Re: cutting product descriptions manually (for listings)

See the Customizing Product Description Text Formatting on Category Page thread for a method with minimal coding to make different descriptions on listing and info pages, including enabling HTML in listing pages.

If you only want to choose the point to truncate the description on the listing page, I believe this would work (not tested yet):

In /includes/modules/your_template/product_listing.php, find thisphp 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">' . 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']), ($_GET['cPath'] > 0 ? 'cPath=' . $_GET['cPath'] . '&' : '') . '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; and beginning at "zen_trunc_string" change to this```php
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;


You would then need to remove the *more* from the description in the info page.
FInd this```php
 <!--bof Product description -->
<?php if ($products_description != '') { ?>
<div id="productDescription" class="productGeneral biggerText"><?php echo stripslashes($products_description); ?></div>
<?php } ?>
<!--eof Product description -->
```and change to this```php
 <!--bof Product description -->
<?php if ($products_description != '') { ?>
<div id="productDescription" class="productGeneral biggerText"><?php echo str_replace("*more*","",stripslashes($products_description)); ?></div>
<?php } ?>
<!--eof Product description -->
9 Oct 2007, 5:06 PM
#4
poosk avatar

poosk

Totally Zenned

Join Date:
Mar 2005
Location:
Helsinki
Posts:
477
Plugin Contributions:
0

Re: cutting product descriptions manually (for listings)

ah wonderful many thanks again G

2 Nov 2007, 7:36 PM
#5
poosk avatar

poosk

Totally Zenned

Join Date:
Mar 2005
Location:
Helsinki
Posts:
477
Plugin Contributions:
0

Re: cutting product descriptions manually (for listings)

Actually I didnt have time to testi this until yet. I tried the more thing but first of all it didn't cut it and second

Warning: Wrong parameter count for strstr() in /home/public_html/store/includes/modules/classic/product_listing.php on line 154

Any idea? appreciate your help a lot though. many thanks

3 Nov 2007, 9:27 AM
#6
gjh42 avatar

gjh42

Black Belt

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

Re: cutting product descriptions manually (for listings)

OK... I think there is a misplaced close parenthesis in the code. There should be three before the "more" and one after, not two and two.```php
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;

4 Nov 2007, 6:31 PM
#7
poosk avatar

poosk

Totally Zenned

Join Date:
Mar 2005
Location:
Helsinki
Posts:
477
Plugin Contributions:
0

Re: cutting product descriptions manually (for listings)

works like a charm. many many thanks!

an another thing is can this be used for the new listing as well? I tried but really couldn't make sense from the new_listing file since the structure is different

and apparently new listing page strips all html from description? so I couldn't use div to hide the rest. if more can not be applied how can I remove html block?

4 Nov 2007, 7:30 PM
#8
gjh42 avatar

gjh42

Black Belt

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

Re: cutting product descriptions manually (for listings)

All of the listing pages strip HTML from the description, and currently each of them has its own file so each one will have to be edited to change this. Search on zen_clean_html and you should find a description of the process - very simple.

The more code should be applicable to all of the listing pages, but as mentioned the files are different so it will take some rooting around to be sure of the right edit location.

The centerboxes are very different, and may not include the description at all, so they would be much more involved to modify.

4 Nov 2007, 7:32 PM
#9
poosk avatar

poosk

Totally Zenned

Join Date:
Mar 2005
Location:
Helsinki
Posts:
477
Plugin Contributions:
0

Re: cutting product descriptions manually (for listings)

thanks gjh actually figured out everything else but I'm still struggling how to remove more text from the new listing. I decided to go with the html so It wont need to cut it but I'd still like to hide the more text?

4 Nov 2007, 7:44 PM
#10
gjh42 avatar

gjh42

Black Belt

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

Re: cutting product descriptions manually (for listings)

This is adding another layer of code, but you could wrap the more tags in

<span class="moreMarker">more</span>

and style

#newProductsDefault .moreMarker {display: none;}

4 Nov 2007, 8:27 PM
#11
poosk avatar

poosk

Totally Zenned

Join Date:
Mar 2005
Location:
Helsinki
Posts:
477
Plugin Contributions:
0

Re: cutting product descriptions manually (for listings)

I thought about it but doesn't it leave open span class to listing pages where more cuts the description.. oh well I don't think it will do any harm though

4 Nov 2007, 8:47 PM
#12
gjh42 avatar

gjh42

Black Belt

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

Re: cutting product descriptions manually (for listings)

Hmm that's right... You could get a little trickier with the cutting and trim the string another 26 characters if it trims at a more...

4 Nov 2007, 9:46 PM
#13
gjh42 avatar

gjh42

Black Belt

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

Re: cutting product descriptions manually (for listings)

I have the feeling we're running into duplication of effort. Are you really using the div hiding for some listings and the more truncating for others?
If you tell me the exact file that applies to the listing you are working on (there are near-duplicates that work on similar-sounding but different places), I will look at it and find the right place to apply the more truncating.

6 Nov 2007, 6:55 PM
#14
poosk avatar

poosk

Totally Zenned

Join Date:
Mar 2005
Location:
Helsinki
Posts:
477
Plugin Contributions:
0

Re: cutting product descriptions manually (for listings)

no everything seems to work perfect for me now. MANY MANY thanks for your effort. Actually I use the span class with more, and applied all html stripping to that specific list so the span tag gets cut. New listing is html but parts of it hidden with css and the product page displays the whole listing.. I think you should make a mod from this since I could imagine lots of people could find it useful. Anyway many thanks again.

28 Mar 2008, 5:13 PM
#15
soxophoneplayer avatar

soxophoneplayer

Totally Zenned

Join Date:
Feb 2008
Posts:
534
Plugin Contributions:
0

Re: cutting product descriptions manually (for listings)

I changed files /tpl_docs_general_info_display.php, and /tpl_docs_product_info.php, and also modified /product_listing.php, all as in post 454486 and corrected the minor error of ) placments according to subsqquent post.

In addition, I stripped the zen_clean_html. And then to my lisitings I added the more

This has nicely cleaned up my listing pages, html in tact, but I still have the more showing on the product pages.

I put

<span class="moreMarker">more</span>

in place of more in a few product descriptions to test it, and I added

#newProductsDefault .moreMarker {display: none;} to my style sheet

With no effect - the more still shows on the product pages. Did I make these edits in the wrong files?

Newbie fumbling in the dark....

http://www.soxophoneplayer.com

18 Sep 2010, 11:21 PM
#16
weirdorecords avatar

weirdorecords

New Zenner

Join Date:
May 2010
Posts:
72
Plugin Contributions:
0

Re: cutting product descriptions manually (for listings)

Just wanted to post a thanks for the code in message #6. Although written a while back now, it just untangled a huge problem for me.