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?
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
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 this
PHP Code:
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 Code:
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 will delete everything after *more* inclusive. It will not truncate the description to the set length if there is no *more*. That could be re-added to the code if desired (making it still more complex!)
You would then need to remove the *more* from the description in the info page.
FInd this
PHP Code:
<!--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 Code:
<!--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 -->
Re: cutting product descriptions manually (for listings)
ah wonderful many thanks again G
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
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 Code:
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;
Hopefully my bleary eyes are seeing this right. Try it and let me know how it works.
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?
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.
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?
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;}