<?php function article_index($content , $domain) { global $CACHE; $tag_cache = $CACHE->readCache('tags'); $matches = array(); $ul_li = ''; $r = "/<h2>([^<]+)<\/h2>/im"; if(preg_match_all($r,$content,$matches)) { foreach($matches[1] as $num => $title) { $content = str_replace($matches[0][$num], '<h2 id="title-'.$num.'">'.$title.'</h2>', $content); $ul_li .= '<li><a href="#title-'.$num.'" title="'.$title.'">'.$title."</a></li>\n"; } $content = "\n<div id=\"article-index\"> <b>[文章目录]</b> <ul id=\"index-ul\">\n" . $ul_li . "</ul> </div>\n" . $content; } 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); } preg_match_all('/href="(.*?)"/', $log_content, $matches); if ($matches) { foreach ($matches[1] as $val) { if (strpos($val, $domain) === false) { $log_content = str_replace('href="' . $val . '"', 'href="' . $val . '" rel="external nofollow" ', $log_content); } } } preg_match_all('/src="(.*?)"/', $log_content, $matches); if ($matches) { foreach ($matches[1] as $val) { if (strpos($val, $domain) === false) { $log_content = str_replace('src="' . $val . '"', 'src="' . $val . '" rel="external nofollow" ', $log_content); } } } return $content; } ?>
#article-index { border: 1px dashed #dedfe1; float: left; margin: 0 20px 20px 0; padding: 0 6px; width: 280px; line-height: 24px; } #article-index b { border-bottom: 1px dashed #ddd; display: block; line-height: 30px; padding: 0 4px; } #index-ul { margin: 5px; line-height: 1.8; } #index-ul li { background: none repeat scroll 0 0 transparent; list-style-type: decimal; padding: 4px 10px; border-left: 1px solid #e2e2e2; border-bottom: 1px solid #e2e2e2; } #index-ul li { list-style: circle outside none; }
查找
<?php echo $log_content; ?>
替换(当然你们自己改过,就不是找这个咯)
<?php echo article_index($log_content);?>
本文转载于老司机博客
本文是介绍:Emlog如何实现主分类以及子分类显示该分类全部分类和分类高亮 我们知道要查询子分类很简单,只需要写一下sql查询一下哪个分类的pid是主分类ID 但是此方法到了子分类就会不显示或者出错,...
获取某页面内容,可以讲自定义页面做为首页 1、在模板module.php中加入如下代码 <?php //调用页面内容 function html_page($id,$echo){$home...
Emlog资源网搭建 二次开发 落地检测 采集定制 等服务 思源资源网担保:Emlog资源网模板设计、插件定制、模板二次修改 广告屏蔽搜索引擎,过落地页检测(不过不收费),模板SE...
Emlog今日文章时间加红 只需要写一个判断,那如果今日未发文则显示昨日时间加红怎么实现呢? 首先我们需要判断一下今日是否发文 把代码放到模板下module.php中 &l...
前言,会员中心用微语做公告用。所以需要会员中心调用 Emlog调用最新微语一条代码 (直接放入你需要显示的地方即可,其中的0表示从第一条开始,可自行设置从第几条开始) <?php $ne...
去掉EMLOG分类url中的sort字样 前言:EMLOG使用伪静态后,分类URL网址中有个sort字样,都想把这个sort去掉;想去除EMLOG伪静态分类网址中的sort,进入include文件夹...