truncate content to certain character count
Posted: Mon Aug 22, 2011 8:21 pm
Hi, I wish to truncate some content to a certain character count. I found that I can do this like this...
{content|truncate:250:"... Read more":true}
However I want the Read more to be a link, for example...
{content|truncate:250:"... <a href="http://link.com">Read more</a>":true}
But... the set of "double quotes" in the link html causes problems. Is there a way to escape these chararcter so they are correctly displayed in the browser?
Also, is there a way to truncate to a word count rather than a chararcter count so the truncate does not cut words off part way through?
Thanks, Steven
{content|truncate:250:"... Read more":true}
However I want the Read more to be a link, for example...
{content|truncate:250:"... <a href="http://link.com">Read more</a>":true}
But... the set of "double quotes" in the link html causes problems. Is there a way to escape these chararcter so they are correctly displayed in the browser?
Also, is there a way to truncate to a word count rather than a chararcter count so the truncate does not cut words off part way through?
Thanks, Steven