Zen Cart Logo
Forums / Bug Reports / Reviews sidebox nl2br before zen_trunc_string

Reviews sidebox nl2br before zen_trunc_string

Views: 795

Results 1 to 1 of 1
4 Mar 2013, 7:36 AM
#1
pasi avatar

pasi

Zen Follower

Join Date:
Mar 2004
Location:
Finland
Posts:
435
Plugin Contributions:
1

Reviews sidebox nl2br before zen_trunc_string

a small bug in includes/templates/template_default/sideboxes/tpl_reviews_random.php

in code:

zen_trunc_string(nl2br(zen_output_string_protected(stripslashes($random_review_sidebox_product->fields['reviews_text']))), 60)

Sometimes when the newline happens to be in the right spot nl2br converts it to <br /> AND zen_trunc_string cuts the string in the middle of the tag.

I noticed this as an broken link in one of my customers shop:

<a href="link-to-review-page">Review text here bla bla bla<br ...</a>

Since the <br> is cut, the browser reads the tag as <br ..</a> and the link doesn't get closed.

Solution:
Swap the nl2br and zen_trunc_string...

nl2br(zen_trunc_string(zen_output_string_protected(stripslashes($random_review_sidebox_product->fields['reviews_text'])), 60))