Jump to content

$product.description_short|truncate problem


Recommended Posts

is there any way of truncating keeping in mind to:

a) close all open html tags

B) only count the text inside the tags?



Or maybe just show the text version of the html text and truncate that?


i have a truncated description in the product list, and many product descriptions contain html divs and spans, which,if not closed properly, cause rendering errors

Link to comment
Share on other sites

Not sure if this would work, but line of code in product-list.tpl that deals with short descriptions is

				<p class="product_desc"><a href="{$product.link|escape:'htmlall':'UTF-8'}" title="{$product.description_short|truncate:360:'...'|strip_tags:'UTF-8'|escape:'htmlall':'UTF-8'}">{$product.description_short|truncate:360:'...'|strip_tags:'UTF-8'}</a></p>


Have you tried swapping the truncate and strip-tags code around so it looks like

				<p class="product_desc"><a href="{$product.link|escape:'htmlall':'UTF-8'}" title="{$product.description_short|strip_tags:'UTF-8'|truncate:360:'...'|escape:'htmlall':'UTF-8'}">{$product.description_short|strip_tags:'UTF-8'|truncate:360:'...'}</a></p>


I'm not too sure whether the order of these two codes makes any difference to what is rendered on screen.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...