欢迎访问 舍力博客(www.shuyong.net)
<?php //分类文章调用 function sort_log($sortid){ $db = MySql::getInstance(); $sql = $db->query ("SELECT * FROM ".DB_PREFIX."blog WHERE sortid='$sortid' AND type='blog' AND hide='n' order by date DESC limit 0,1"); $row = $db->fetch_array($sql); if (!empty($row['excerpt'])){ preg_match_all("|<img[^>]+src="([^>"]+)"?[^>]*>|is", $row['excerpt'], $match); if(empty($match[0][0])) {preg_match_all("|<img[^>]+src="([^>"]+)"?[^>]*>|is", $row['content'], $match);} }else{preg_match_all("|<img[^>]+src="([^>"]+)"?[^>]*>|is", $row['content'], $match);} $logpost = !empty($row['excerpt']) ? $row['excerpt'] : ''.$row['content'].''; $num = rand(1,$imgnum); $img = isset($match[0][0]) ? $match[0][0] : '<img src="'.TEMPLATE_URL.'images/shuyong_net/'.$num.'.jpg">'; $content = strip_tags($logpost,''); $content = mb_substr($content,0,68,'utf-8');// $out .='<div class="sort-tw"><div class="sort-img"><a href="'.Url::log($row['gid']).'" title="'.$row['title'].'" >'.$img.'</a></div> <div class="sort-tt"><a href="'.Url::log($row['gid']).'" title="'.$row['title'].'" >'.$row['title'].'</a></div><div class="sort-nr">'.$content.'...</div></div> '; $sort_log_num = $sort_log_num -1; $logs = $db->query ("SELECT * FROM ".DB_PREFIX."blog WHERE sortid='$sortid' AND type='blog' AND hide='n' order by date DESC limit 1,10");//1表示从第2篇文章开始,10为数量 while ($trow = $db->fetch_array($logs)){ $date = gmdate('m-d', $trow['date']); $trow['title'] = mb_substr($trow['title'],0,180,'utf-8'); $out .='<li><p><a href="'.Url::log($trow['gid']).'" title="'.$trow['title'].'">'.$trow['title'].'</a></p><span>'.$date.'</span></li> '; }echo $out;}?>Emlog模板文件log_list.php下使用如下代码
留言/评论:◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。