打开我们主题的module.php文件添加如下代码:
//自动为文章标签添加该标签的链接
function tag_link($content){
    global $CACHE;
        $tag_cache = $CACHE->readCache('tags');
        foreach($tag_cache as $value){
                $tag_url = Url::tag($value['tagurl']);
                $keyword = $value['tagname'];
                $cleankeyword = stripslashes($keyword);
                $url = "<a href=\"{$tag_url}\" title=\"浏览关于“{$cleankeyword}”的文章\" target=\"_blank\" >{$cleankeyword}</a>";
                $regEx = '\'(?!((<.*?)|(<a.*?)))('. $cleankeyword . ')(?!(([^<>]*?)>)|([^>]*?</a>))\'s';
                $content = preg_replace($regEx,$url,$content);
        }
        return $content;
}
其次在echo_log.php中将 <?php echo $log_content; ?> 修改成 <?php echo tag_link($log_content); ?> 即可。
    






发表评论: