分享自定義函數(shù)解決帝國(guó)cms的簡(jiǎn)介截取字符時(shí)出現(xiàn)html的問(wèn)題
發(fā)布時(shí)間:2019-12-09 來(lái)源:未知 瀏覽: 關(guān)鍵詞:帝國(guó)CMS
我的解決方法如下,寫(xiě)了個(gè)函數(shù)加進(jìn)去,大家看看是否可行,有咩有問(wèn)題,我感覺(jué)還行
首先在 e/class/connect.php 文件中加入一個(gè)自定義函數(shù) 比如 NoHTML() 這個(gè)自己喜歡隨便設(shè)置
代碼如下:
//去除HTML標(biāo)記function NoHTML($string){$string = preg_replace("'<script[^>]*?>.*?</script>'si", "", $string);//去掉javascript$string = preg_replace("'<[///!]*?[^<>]*?>'si", "", $string); //去掉HTML標(biāo)記$string = preg_replace("'([/r/n])[/s]+'", "", $string); //去掉空白字符$string = preg_replace("'&(quot|#34);'i", "", $string); //替換HTML實(shí)體$string = preg_replace("'&(amp|#38);'i", "", $string);$string = preg_replace("'&(lt|#60);'i", "", $string);$string = preg_replace("'&(gt|#62);'i", "", $string);$string = preg_replace("'&(nbsp|#160);'i", "", $string);return $string;}
推薦學(xué)習(xí)《帝國(guó)cms教程》
然后去列表內(nèi)容模板修改代碼即可
代碼如下:
$r[smalltext]=esub(NoHTML($r[smalltext]),200,'......');$listtemp='<li><strong><a href="[!--titleurl--]">[!--title--]</a></strong><p>[!--smalltext--]</p></li>';
這樣問(wèn)題就解決了,很簡(jiǎn)單吧.
由于是中英文的網(wǎng)站,網(wǎng)站名稱需要用到標(biāo)題,所以這樣修改就很方便了
以上就是分享自定義函數(shù)解決帝國(guó)cms的簡(jiǎn)介截取字符時(shí)出現(xiàn)html的問(wèn)題的詳細(xì)內(nèi)容,更多請(qǐng)關(guān)注魔酷閣其它相關(guān)文章!
責(zé)任編輯:實(shí)速科技