折雨的天空
wecenter3.3.1的bbcode对老的文章显示支持有点问题
2019-4-8 我好笨


原来老的文章不会换行了



图片也不换行了,看起好丑。



历史文章,如果是以html模式发布的呢,首页又不支持摘要。



先解决第一个问题:







老的bbcode不支持换行的问题。







需要修改两个文件,web端:



app\article\main.php



第67行附近:



$article_info['message']=preg_replace('~[\n]~Uis','<br />',$article_info['message']);
$article_info['message'] = html_entity_decode(FORMAT::parse_attachs((FORMAT::parse_bbcode($article_info['message']))));



第一句是增加的,第二句是原来的。







同样移动端,app\m\main.php



第1176行附近,改为:



$article_info['message']=preg_replace('~[\n]~Uis','<br />',$article_info['message']);
$article_info['message'] = html_entity_decode(FORMAT::parse_attachs((FORMAT::parse_bbcode($article_info['message']))));



第一句是增加的,第二句是原来的。











换行问题解决。







第二个问题,html模式发布,首页不支持摘要的问题,只有web端会出现。



修改模板文件,views\default\explore\ajax\list.tpl.htm 的第50行左右,改为:







<?php echo mb_substr(strip_tags(html_entity_decode(nl2br(trim(strip_tags(FORMAT::parse_attachs(FORMAT::parse_bbcode($val['message']))))))),0,130,'utf-8'); ?> <?php if (cjk_strlen($val['message']) > 130) { ?>





问题主要原因是内容如果有图片之类的,截取的mb_substr函数在strip_tags之前,造成截取到Html源代码了。

发表评论:
昵称

邮件地址 (选填)

个人主页 (选填)

内容