0
在使用smarty模板的文章網站上,我需要截斷主要內容以創建預告片。我可以通過字符截斷,但第一段的長度是完全未知的文章。 我想要的東西更聰明,只是表明第一段:將內容截斷爲Smarty的第一段
內容:
This is my first paragraph and I want to display this and only this.
This the rest of the content and it is very long with a lot of words...
預告:
This is my first paragraph and I want to display this and only this.
感謝您指出我朝着正確的方向。 使用這個我可以解決我的問題的第二部分,如何隱藏我的內容第一段取出多後旗: '{*刪除第一個段落*}' '{的preg_replace('/ ^。 *?<\/p> /是','',$ content)}' 但是我試圖只顯示第一段失敗。 您在上面發佈的代碼僅顯示「三次(我的內容有3段) 刪除多行標誌只顯示一個」和另一段落。 '{preg_replace('/^.*?<\/p>/is','$ 1「',$ content)}' –