1.给UCHOME_BLOG表增加tuijian int(1)和tjsj(datetime)字段.
2.修改source\network.php中代码:
//日志
//$cachefile = S_ROOT.'./data/cache_network_blog.txt';
//if(check_network_cache('blog')) {
// $bloglist = unserialize(sreadfile($cachefile));
//} else {
$sqlarr = mk_network_sql('blog',
array('blogid', 'uid'),
array('hot','viewnum','replynum'),
array('dateline'),
array('dateline','viewnum','replynum','hot')
);
extract($sqlarr);
//隐私
$wherearr[] = "main.friend='0'";
//显示数量
$shownum = 6;
$query = $_SGLOBAL['db']->query("SELECT main.*, field.*
FROM ".tname('blog')." main
LEFT JOIN ".tname('blogfield')." field ON field.blogid=main.blogid
WHERE ".implode(' AND ', $wherearr)."
ORDER BY main.{$order} $sc LIMIT 0,$shownum");
$bloglist = array();
while ($value = $_SGLOBAL['db']->fetch_array($query)) {
$value['message'] = getstr($value['message'], 86, 0, 0, 0, 0, -1);
$value['subject'] = getstr($value['subject'], 50, 0, 0, 0, 0, -1);
$bloglist[] = $value;
}
if($_SGLOBAL['network']['blog']['cache']) {
swritefile($cachefile, serialize($bloglist));
}
//}
foreach($bloglist as $key => $value) {
realname_set($value['uid'], $value['username']);
$bloglist[$key] = $value;
}
//精选推荐
$sqlarr = mk_network_sql('blog',
array('blogid', 'uid'),
array('hot','viewnum','replynum'),
array('dateline'),
array('dateline','viewnum','replynum','hot')
);
extract($sqlarr);
//隐私
$wherearr[] = "main.friend='0'";
//显示数量
$shownum1 = 7;
$query = $_SGLOBAL['db']->query("SELECT main.*, field.*
FROM ".tname('blog')." main
LEFT JOIN ".tname('blogfield')." field ON field.blogid=main.blogid
WHERE ".implode(' AND ', $wherearr)." AND tuijian=1
ORDER BY main.tjsj desc LIMIT 0,$shownum1");
$bloglist1 = array();
while ($value = $_SGLOBAL['db']->fetch_array($query)) {
$value['message'] = getstr($value['message'], 86, 0, 0, 0, 0, -1);
$value['subject'] = getstr($value['subject'], 50, 0, 0, 0, 0, -1);
$bloglist1[] = $value;
}
if($_SGLOBAL['network']['blog']['cache']) {
swritefile($cachefile, serialize($bloglist1));
}
function msubstr($str, $start, $len) {
$tmpstr ="";
$strlen = $start + $len;
for($i = 0; $i < $strlen; $i++) {
if(ord(substr($str, $i, 1)) > 0xa0) {
$tmpstr .= substr($str, $i, 2);
$i++;
} else
$tmpstr .= substr($str, $i, 1);
}
return $tmpstr;
}
foreach($bloglist1 as $key => $value) {
realname_set($value['uid'], $value['username']);
$value['subject']=msubstr($value['subject'],0,40);
$bloglist1[$key] =$value;
}
3.修改template\default\network.htm和network.css增加推荐版块,network.htm推荐版块代码如下:
<div class="main_right">
<div class="bt">
<h4>精选推荐</h4>
</div>
<ul class="tj_list">
<!--{loop $bloglist1 $key $value}-->
<li><span class="red1">[推荐]</span> <a href="space.php?uid=$value[uid]&do=blog&id=$value[blogid]"
target="_blank">$value[subject]</a></li>
<!--{/loop}-->
</ul>
</div>
4.后台日志管理增加推荐功能:
修改admin\admincp_blog.php中
if($_GET['op'] == 'tuijian') {
//推荐日志
$tjrzid=$_GET['id'];
$_SGLOBAL['db']->query("UPDATE ".tname('blog')." SET tuijian=1,tjsj=now() WHERE blogid='$tjrzid'");
cpmessage('do_tjsuccess', 'admincp.php?
ac=blog&orderby='.$orderby.'&ordersc=desc&perpage='.$perpage.'&page='.$page.'&username='.$_GET
['username'].'&searchsubmit='.$_GET['searchsubmit']);
}
修改tpl\blog.htm中
<td>
<a href="admincp.php?ac=blog&op=tuijian&username=$_GET[username]&searchsubmit=$_GET
[searchsubmit]&id=$value[blogid]&orderby=blogid&ordersc=desc&perpage=$perpage&page=$page">推荐</a> <a href="cp.php?
ac=blog&op=edit&blogid=$value[blogid]" target="_blank">编辑</a>
<a href="admincp.php?ac=comment&id=$value[blogid]&idtype=blogid">评论</a>
</td> |