You are here:  » %Description% appearing in related when no description is available.


%Description% appearing in related when no description is available.

Submitted by twdesigns on Mon, 2013-03-25 13:59 in

I was doing some manual changes to my site based on code found here and noticed today that my featured products with no description just say "... more information" but under related products after viewing a production page it says "%description% ... more information".

Where would I need to look and what would I need to change so that it excludes the code %description% from appearing if there is no product description under related items?

Thanks,
Tommy

Submitted by support on Mon, 2013-03-25 14:17

Hi Tommy,

In your modified Featured Products / Each template (wp-admin > Settings > PriceTapestry.org), if instead of %DESCRIPTION%, use the custom field placeholder %DB_description% that will either be replaced out with the description (if set) or blank if not set...

Cheers,
David.
--
PriceTapestry.com

Submitted by twdesigns on Mon, 2013-03-25 15:55

That did the trick! Thank you David.

Submitted by twdesigns on Tue, 2013-03-26 02:03

One more question related to this topic. How can I limit the number of words that appear under related, which I assume are generated by the search results each. As of right not it's pulling in the whole description under related products.

%DB_description%... <a href='%PRODUCT_URL%'>More Information</a>
This is what I have.

Submitted by support on Tue, 2013-03-26 07:51

Hi Tommy,

The description displayed in search results / related products (which uses the search results template), via the standard %DESCRIPTION% placeholder, is limited to 200 characters (or nearest space) by this code at line 466 of pto_search.php:

      $each = str_replace("%DESCRIPTION%",pto_common_substr($row->description,200,"..."),$each);

For a different length, either adjust the constant 200 in that line as required, or for the full description, REPLACE with just:

      $each = str_replace("%DESCRIPTION%",$row->description,$each);

Cheers,
David.
--
PriceTapestry.com

Submitted by twdesigns on Tue, 2013-03-26 15:27

Hey David,

I can get one or the other to work but not both.

What I want done is my RELATED PRODUCTS to show a description and cut off after 200 characters. I had modified my files to allow the description field to appear. But as the first post stated if the product doesn't have a description it would show %DESCRIPTION% instead of just being blank. I used your above solution to the first question which fixed my problem but I noticed that the descriptions for related products were not cutting off after 200 characters and instead showing all the text. I located the code in your second suggestion and it was set for 200, I changed it to 100 and it does work for SEARCHES but does not change my RELATED PRODUCTS.

I assume it's because I'm using %DB_description% and not %DESCRIPTION%.

What would be the best way to correct my issue?

Submitted by support on Tue, 2013-03-26 15:36

Hi Tommy,

Since search results and related products are both displayed by the same code (search results HTML) some conditional code would be required to perform the truncation only if the code is displaying related products.

This is straight forward, since if the variable $pto_product is set, then we are showing related products, else, we are showing search results.

So in pto_search.php, instead of the replacement described above, use:

      global $pto_product;
      if ($pto_product)
      {
        $each = str_replace("%DESCRIPTION%",pto_common_substr($row->description,200,"..."),$each);
      }
      else
      {
        $each = str_replace("%DESCRIPTION%",$row->description,$each);
      }

Search results will then show the full description, related products will cropped to 200 characers (to the next space)...

Cheers,
David.
--
PriceTapestry.com

Submitted by twdesigns on Tue, 2013-03-26 18:33

Thank you David!