Re: [SMARTY] truncate() and HTML
| From: | Werner | Date: | Tue, 22 Mar 2005 06:51:25 +0000 |
| Subject: | Re: [SMARTY] truncate() and HTML | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-12351@lists.php.net to get a copy of this message | ||
Hi!
I know this does not answer your question directly, but is it really necessary to include the user's orgiginal tags/formatting in the truncated text? Normally, I strip the tags from user comments/posts/content before sending it to the template, especially if it is going to be truncated (as truncation pre-supposes introduction (or similar) text, which is not normally expected to contain formatting). The designer will have more freedom and flexibility if stripped text is passed to the template, especially if it is expected to be truncated. Stripping tags also makes sense if you strive towards an uncomplicated template for the designer.
Maximillian Schwanekamp wrote:
Hello, What is the best method for dealing with unclosed HTML tags resulting from truncate() in the Smarty template? Is there some method which I haven't noticed for closing unclosed tags from Smarty itself, or should I be using a regex from within my application? I was hoping to avoid the latter, so as to allow the designer flexibility as to the amount of content being displayed. Specifically, I have blocks of user-entered content that contains simple HTML (a,strong,img,em). Occasionally truncate() will chop the string in between <strong> and </strong> (for example), which throws my final output markup out of whack (a whole block gets <strong>'ed in this example). Any suggestions?