post by tommy @ 21 十月, 2012 15:41
前幾天在有人新增 comment 之後, 發現整個網站的顯示格式大亂. 找了一下, 發現是在顯示最近留言功能裡頭, 會把留言截短之後再透過 strip_tags 處理. 像是這樣:
<li><a title="View comments by {$comment->getUsername()}" href="{$url->postPermalink($commentpost)}#{$comment->getId()}"><b>{$comment->getUsername()}¡G</b>{$comment->getText()|truncate:100:"..."|strip_tags}</a></li>
但是, 先做 truncate, 就可能造成 tag 變成有頭沒有尾, 所以後面的 strip_tags 也就沒什麼作用了.
改成先做 strip_tags 再去處理 truncate 就應該可以避免這個問題了.
<li><a title="View comments by {$comment->getUsername()}" href="{$url->postPermalink($commentpost)}#{$comment->getId()}"><b>{$comment->getUsername()}¡G</b>{$comment->getText()|strip_tags|truncate:100:"..."}</a></li>
改好後看起來就正常了. (如果怕有其它的情形... 也許後面再加上一個 escap 來濾掉一些字元也可以)
post by tommy @ 25 十一月, 2011 09:30
Server 改用 nginx/fastcgi/php-fpm 的方式執行. 由於新加入的 php5-intl 與原本的 Locale 衝突, 所以順便升級到 1.2.12 2011/11/24 的 snapshot 版本.
post by tommy @ 31 三月, 2008 11:15
post by tommy @ 04 四月, 2007 21:51
新增 TinyMCE 的 insertcode 外掛, 並修正某些外掛無法使用 gzip 壓縮的問題. (閱讀全文)
post by tommy @ 21 三月, 2007 11:35
upgrade to LifeType 1.2
新增一些書籤網站的連結在每篇文章後面. 並修正 LifeType 1.2 對於 & 的處理問題.
post by tommy @ 02 二月, 2007 17:11
post by tommy @ 12 元月, 2007 14:43
post by tommy @ 04 十二月, 2006 08:43
post by tommy @ 02 八月, 2006 13:48