帝国cms统计文章字数和阅读时长?

帝国CMS教程 2021-06-23 10:00:02 231

怎样把下面的改成帝国能用的

把下面这个代码放在 e/class/userfun.php 里面

// 阅读时间
function count_words_read_time () {
        global $post;
        $text_num = mb_strlen(preg_replace('/\s/','',html_entity_decode(strip_tags($post->post_content))),'UTF-8');
        $read_time = ceil($text_num/300); // 修改数字300调整时间
        $output .= '本文共计' . $text_num . '个字,预计阅读时长' . $read_time  . '分钟。';
        return $output;
}

调用代码:
<?php echo count_words_read_time(); ?>

可以

要global $navinfor;
然后处理字段内容用$navinfor[字段名]

声明:资源来自网络转载,版权归原作者所有,与本站立场无关,如不慎侵犯了你的权益,请联系我们告知,将做删除处理!

原文地址:《帝国cms统计文章字数和阅读时长?》发布于2021-06-23 10:00:02