oarecare Posted July 31, 2011 Share Posted July 31, 2011 is there any way of truncating keeping in mind to: a) close all open html tags 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 More sharing options...
jhnstcks Posted July 31, 2011 Share Posted July 31, 2011 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 More sharing options...
oarecare Posted August 1, 2011 Author Share Posted August 1, 2011 you're a lifesaver. Stripping the tags prior to truncating did the trick Link to comment Share on other sites More sharing options...
jhnstcks Posted August 1, 2011 Share Posted August 1, 2011 Glad to help Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now