Emlog同分类下的上下篇文章功能实现

2020-02-29 13:05:55 / 0 评论 / 3320 阅读 / 正在检测是否收录...

将下面代码放入模板文件module.php中

<?php
//shuyong.net:同分类相邻文章
function nextLog($logid, $sortid, $flag, $pattern=0){
$Log_Model = new Log_Model();if($flag == 'prev'){$sql = " AND gid < $logid ORDER BY gid DESC";$word = '上一篇';}
else{$sql = " AND gid > $logid ORDER BY gid ASC";$word = '下一篇';}
$log = $Log_Model -> getLogsForHome(" AND sortid = $sortid "."$sql", 1, 1);
if($log){foreach($log as $value):?>
<?php echo $word;?>:<a href="<?php echo $value['log_url'];?>" title="<?php echo $value['log_title'];?>"><?php echo $value['log_title'];?></a>
<?php endforeach;}else{echo $word.':没有了';    }
}?>

然后在echo_log.php相应位置放入

<?php nextLog($logid, $sortid, 'prev'); nextLog($logid, $sortid, 'next');?>

评论

取消