Zen Cart Logo
Forums / Templates, Stylesheets, Page Layout / Add more info link to product listing description when description is truncated

Add more info link to product listing description when description is truncated

Locked

Views: 7,077

Results 1 to 12 of 12
This thread is locked. New replies are disabled.
26 Jan 2009, 11:23 PM
#1
maureent avatar

maureent

New Zenner

Join Date:
Nov 2008
Posts:
60
Plugin Contributions:
0

Add more info link to product listing description when description is truncated

First of all, this is for ZC version 1.3.8. There may be some differences in earlier versions.

On the All Products page, when a product's description is truncated (does not all display because it's too long), a More Info link appears at the end of the description. For some reason, the Product Listing page was not coded this way. Instead, all you get is an ellipse at the end of the truncated description, which isn't enough for the unobservant shopper.

I found solutions that would add the link to the product listing description, but all the ones I found add the link regardless of whether or not the description is truncated, in other words, even when there actually is no other information to go see.

Upon taking a look at how the link code works on the All Products page, I managed to get it to work properly on the Product Listing page, appearing only when it should. I figured that others might want to do this as well, so here are the instructions.

You'll be changing one file: product_listing.php. If you have made no previous alterations to that file, look for it in /includes/modules/. Once you've made the changes, put it in /includes/modules/your_template/. Do not apply the changes to the default file.

In the above file, find the following code (within lines 98 and 100 if no previous changes have been made to the file):

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

Replace with:

<div class="listingDescription">' . zen_trunc_string(zen_clean_html(stripslashes(zen_get_products_description($listing->fields['products_id'], $_SESSION['languages_id']))), PRODUCT_LIST_DESCRIPTION, ' <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']) . '">' . MORE_INFO_TEXT . '</a>') . '</div>';

IMPORTANT: There are two places in the file that have this code. Be sure to change both.

And that's it. You should now get a more info link after every truncated description on the Product Listing page but not when the description is all there, just like you do on the All Products page. :clap:

Be aware that if a product has attributes, there will now be two 'more info' links, the one at the end of the description and the one in the usual spot in place of the Buy Now or Add to Cart button.

28 Jan 2009, 3:24 PM
#2
outdoorsinteriors avatar

outdoorsinteriors

Zen Follower

Join Date:
Jan 2007
Posts:
104
Plugin Contributions:
0

Re: Add more info link to product listing description when description is truncated

This is TERRIFIC and a big thank you...:). One problem I have with this though, is when I click on "New Products" it is at the end of my description, it shows a number associated to the category product ID and the "more info" is under my image. I'd like it to be exactly displayed the same as my Product Listing on main categories. Any ideas how to fix?

http://outdoorsinteriors.com

Thanks again

OI

28 Jan 2009, 5:24 PM
#3
maureent avatar

maureent

New Zenner

Join Date:
Nov 2008
Posts:
60
Plugin Contributions:
0

Re: Add more info link to product listing description when description is truncated

This must have been a problem that you had before because this mod doesn't affect your New Products page at all, unless your site is set up to use the same layout for New Products as the Product Listing page. If you'd like to do that, you should check out:

http://www.zen-cart.com/forum/showthread.php?t=84174&highlight=using+one+single+listing+template&page=8

The instructions are for changing the All Products page, but it can be used for New Products as well, though a wee bit of understanding of the code (or help in doing it) would probably be needed. I applied it to my All Products page, and it works great.

Anyhow, back to your problem. I don't use the New Products page, so I just turned it on to take a look at it on my site. The more info link under the image is the one you get in place of your Buy Now button when a product has attributes. That has nothing to do with the description being truncated. As for the category ID number showing up at the end of your description, I don't think it should be doing that. Mine doesn't. I took a quick look at the code for that part of the page, and I see nothing that would cause the ID number to display. Have you installed a contribution that made changes to /includes/templates/template_default/templates/tpl_modules_products_new_listing.php? That file should be in /includes/templates/your_template/templates/ if you did, unless you changed the default file itself.

If no changes were made to that file, there should be the following code at or around line 107 (if you're using ZC version 1.3.8):

      if (PRODUCT_NEW_LIST_DESCRIPTION > '0') {
        $disp_text = zen_get_products_description($products_new->fields['products_id']);
        $disp_text = zen_clean_html($disp_text);

        $display_products_description = stripslashes(zen_trunc_string($disp_text, PRODUCT_NEW_LIST_DESCRIPTION, '<a href="' . zen_href_link(zen_get_info_page($products_new->fields['products_id']), 'cPath=' . zen_get_generated_category_path_rev($products_new->fields['master_categories_id']) . '&products_id=' . $products_new->fields['products_id']) . '"> ' . MORE_INFO_TEXT . '</a>'));
      } else {
        $display_products_description = '';
      }

This is the code that displays the product description, truncates it if it's too long, and puts the More Info link at the end if the description is truncated. If it doesn't look like that in your tpl_modules_products_new_listing.php file, something has been changed and, apparently, caused a bug in the code.

Could you give me a URL to the New Products page that's doing this so that I can see for myself what's happening? I went to your site, but it doesn't have the New Products page activated.

Personal note about your site: You should consider having product images display on all your product listing pages. Shoppers want to be able to see at a glance what a product looks like rather than having to click through to the Product Info page.

28 Jan 2009, 5:32 PM
#4
maureent avatar

maureent

New Zenner

Join Date:
Nov 2008
Posts:
60
Plugin Contributions:
0

Re: Add more info link to product listing description when description is truncated

Never mind. I guess I must be blind today. I didn't even see your New Products sidebox. I took a look at your new products page, and, yeah, that's weird. When I get some time, I'll look at the source code and see what's going on, though I'd actually need to see your tpl_modules_products_new_listing.php file to really see what's happening.

28 Jan 2009, 5:43 PM
#5
maureent avatar

maureent

New Zenner

Join Date:
Nov 2008
Posts:
60
Plugin Contributions:
0

Re: Add more info link to product listing description when description is truncated

It's me again. I couldn't tell a thing from your source code. The key to what's causing this should be in that file I mentioned. This is very definitely a bug in the code. As for that More Info link under the image, that is what shows instead of the quantity box if a product has an attribute/option. if you take a look at "Bear & Cub Rustic Fireplace Screen" on page 2, you'll see that it has the quantity box instead of the More Info link because there are no attributes.

28 Jan 2009, 8:40 PM
#6
outdoorsinteriors avatar

outdoorsinteriors

Zen Follower

Join Date:
Jan 2007
Posts:
104
Plugin Contributions:
0

Re: Add more info link to product listing description when description is truncated

A BIG THANK YOU for the help and responsiveness. I almost have it all fixed. Only thing now I'm trying to do is get the description in "New Products" lined up the same way as when you click on a given product from "Catgories".........aligned center from the image with price on the right and name centered. Hopefully this makes sense. Just want the formatting to look the same on "New Products" as when you click on a given product category.

Thanks so much...:)

OI

28 Jan 2009, 9:15 PM
#7
maureent avatar

maureent

New Zenner

Join Date:
Nov 2008
Posts:
60
Plugin Contributions:
0

Re: Add more info link to product listing description when description is truncated

You're very welcome. :smile:

The problem is that All Products, New Products, Featured Products, Specials and Product Listing each have their own template layout, so they don't all look the same. I don't know why they were designed that way. It would make more sense for every page to have a consistent appearance.

To do what you want, you'll probably have to use that mod that I gave you the link to. With it, you can make your New Products page look like the product listing pages, which are the pages you see when you click on a category. Unfortunately, the instructions there could be pretty confusing for anyone who has absolutely no coding skills at all. I'm just learning (thanks to the gazillion mods I've made to this store), and I was able to do it.

Here is the link again. This one is corrected. The last one I gave you went to page 8, which isn't right.

http://www.zen-cart.com/forum/showthread.php?t=84174&highlight=using+one+single+listing+template

Be sure to read the messages on the first 5 pages. There are some corrections and further explanations and instructions, including some stuff about changing the New Products page. You should glance through the rest of the pages as well. I never went through them all since I didn't need to.

I must stress that for major changes like this, test them out on a test site first. Don't experiment on your live site.

28 Jan 2009, 9:55 PM
#8
outdoorsinteriors avatar

outdoorsinteriors

Zen Follower

Join Date:
Jan 2007
Posts:
104
Plugin Contributions:
0

Re: Add more info link to product listing description when description is truncated

Last post did not go through so trying again here...:). Thanks again and I'll try the mod.

On a side note: My main page do you have any idea how I can position the DHL logo truck right at the end of "FREE SHIPPING All Products"? to fill up that white space?

Thanks

OI

29 Jan 2009, 5:23 AM
#9
maureent avatar

maureent

New Zenner

Join Date:
Nov 2008
Posts:
60
Plugin Contributions:
0

Re: Add more info link to product listing description when description is truncated

The only way I can think of at the moment to do what you want would be to put that text and the graphic in nested containers you create in your stylesheet. You'd do something like this:

.container {
	width: 500px;
	position: relative;
	height: 72px;
}
.leftBox {
	width: 395px;
	position: relative;
	top: 16px;
}
.rightBox {
	width: 105px;
	left: 395px;
	top: 0px;
	position: absolute;
}

Then, you'd put your text and logo inside <div> tags like this:

<div class="container">
<div class="leftBox"><p><strong>Free Shipping and No Sales Tax...</strong>
<br>It's simple....we offer <strong><font color="#cc0000">FREE SHIPPING</font></strong> on ALL products.</div>
<div class="rightBox"><img id="graphicFiller1" src="includes/templates/gloss_blue/images/dhllogo.bmp" width="105" height="72"></div>
</div>

You'll need to change the size of .container and .leftBox and the position of .rightBox so that the text fits properly, and you might have to increase or decrease 'top: 16px' in .leftBox to get the text perfectly centered, but that should work for you.

Of course, placing the logo to the left with the "Free Shipping and No Sales Tax... It's simple....we offer FREE SHIPPING on ALL products." to the right of it would be much easier to accomplish.

30 Jan 2009, 1:41 AM
#10
outdoorsinteriors avatar

outdoorsinteriors

Zen Follower

Join Date:
Jan 2007
Posts:
104
Plugin Contributions:
0

Re: Add more info link to product listing description when description is truncated

Thanks again for all the help....I'll give that a shot....:)

4 Feb 2010, 3:28 PM
#11
provida avatar

provida

Zen Follower

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

Re: Add more info link to product listing description when description is truncated

If i just need to add a pop up text link to product page, how do i do that?

16 Sep 2010, 4:44 PM
#12
mikestaps avatar

mikestaps

Zen Follower

Join Date:
Aug 2010
Location:
Grand Blanc, MI
Posts:
305
Plugin Contributions:
1

Re: Add more info link to product listing description when description is truncated

MaureenT-
Thank you so much for posting this code, it works great!
I am trying to include the text for product in the more info link as well, basically so that where ever the customer clicks it takes them to the entire porduct description. I have tried a few times with no success...

Attempt 1:

<div class="listingDescription">' . zen_trunc_string(zen_clean_html(stripslashes(zen_get_products_description($listing->fields['products_id'], $_SESSION['languages_id']))),'<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']) . '">' PRODUCT_LIST_DESCRIPTION '</a>', <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']) . '">' . MORE_INFO_TEXT . '</a>') . '</div>';

Attempt 2:

<div class="listingDescription">' . zen_trunc_string(zen_clean_html(stripslashes(zen_get_products_description($listing->fields['products_id'], $_SESSION['languages_id']))),<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']) . '">' PRODUCT_LIST_DESCRIPTION, '  . MORE_INFO_TEXT . '</a>') . '</div>';

The end result of both is no products showing up at all.
Any idea what I'm doing wrong?
TIA
mike