最新置顶头条文章标题加摘要显示的效果,把以下代码复制到module.php里面,如需调用分类置顶文章请把top='y'改为sortop='y'即可- <?php- a6 F# A% q5 i# v
- //首页置顶头条,不带图片5 u0 X% G y% s4 ]5 f `- y
- function sheli_zdLog() {
G% p6 \6 X0 h L7 w6 d - $db = MySql::getInstance();1 F9 O, Y9 Z" X' Q# v* x
- $sql = "SELECT gid,title,content,date FROM ".DB_PREFIX."blog WHERE type='blog' and top='y' ORDER BY `top` DESC ,`date` DESC LIMIT 0,1";) h& Y: V$ i! u
- $list = $db->query($sql);
1 N4 Y+ L! R& w9 | - while($row = $db->fetch_array($list)){
5 ?. ?- `3 l0 U - //$row['content'] = htmlspecialchars($row['content']);+ |: W2 j3 a2 A$ a* k5 n: n. D
- $row['content'] = strip_tags($row['content']);?>
! @( z/ h) I* Q+ o* W: m - <h1><a href="<?php echo Url::log($row['gid']); ?>" title="<?php echo $row['title']; ?>" target="_blank"><?php echo $row['title']; ?></a></h1>2 G! h9 m0 i$ _7 p
- <span class="note"><?php echo mb_substr($row['content'],0,85,'utf-8'); ?>...</span><a href="<?php echo Url::log($row['gid']); ?>" target="_blank">阅读全文>></a> 1 Q; ]/ O4 F: Q5 J) J
- <?php } ?>& U5 M: c3 p2 p6 P
- <?php } ?>
复制代码 如果需要带图片请使用下面代码放入module.php中,如需调用首页置顶文章请把sortop='y'改为top='y'即可- <?php //分类置顶头条,带图片
( a: r( _0 ?9 l1 [ - function sheli_zdLog(){ $db = MySql::getInstance(); $sql = $db->query ("SELECT * FROM ".DB_PREFIX."blog inner join ".DB_PREFIX."sort WHERE hide='n' AND type='blog' AND sortop='y' AND sortid=sid order by date DESC limit 0,5"); while($row = $db->fetch_array($sql)){ if (!empty($row['excerpt'])){ preg_match_all("/\<img.*?src\="(.*?)"[^>]*>/i", $row['excerpt'], $match); if(empty($match[0][0])) { preg_match_all("/\<img.*?src\="(.*?)"[^>]*>/i", $row['content'], $match); } }else{ preg_match_all("/\<img.*?src\="(.*?)"[^>]*>/i", $row['content'], $match); } $logpost = !empty($row['excerpt']) ? $row['excerpt'] : ''.$row['content'].''; $num = rand(1,3); $img = isset($match[0][0]) ? $match[0][0] : '<img src="'.TEMPLATE_URL.'images/shuyong_net/'.$num.'.jpg">'; $date = gmdate('Y年m月d日', $row['date']); $content = strip_tags($logpost,''); $content = mb_substr($content,0,250,'utf-8');$comment = ($row['comnum'] != 0) ? '被吐槽<span>'.$row['comnum'].'</span>次' : '暂无吐槽'; $gid = $row['gid']; $tag = $db -> query("SELECT * FROM ".DB_PREFIX."tag WHERE gid LIKE '%,$gid,%'"); $out .='
/ [: g! p7 a: D8 S5 G5 f8 p v; k - <div class="flash_img2">
; f/ Z% A0 J: V) Y - <div class="hdp_img"><a href="'.Url::log($row['gid']).'" title="'.$row['title'].'" >'.$img.'</a></div>
/ M9 r6 Y3 |( V6 v5 @. K) ] - <div class="hdp"><h4><a href="'.Url::log($row['gid']).'" title="'.$row['title'].'">'.$row['title'].'</a></h4>& S$ ], t5 j# Z, m; O
- <h5>日期:'.$date.' 分类:<a href="'.Url::sort($row['sortid']).'" title="查看 '.$row['sortname'].' 中的全部文章" rel="category tag">'.$row['sortname'].'</a> 共被围观 '.$row['views'].' 次 '.$comment.'</h5> 1 w; {, v7 V8 g. P
- <h6>'.$content.'...</h6></div></div>0 I# P1 ?8 z3 J' L) Z
- '; } echo $out; }?>
复制代码 以上未提供CSS代码,请自行折腾
# H. m, q. \( |# J3 f0 B& \4 T# E2 H' J |