根据分类ID获取文章列表,可主可次。
食用方法跟文章列表一样-.-
<?php
/**
* 获取主分类旗下文章
* @param $sortid 分类ID
* @param $num 数量
* @return string
*/
function whole_category($sortid,$num = 10)
{
global $CACHE;
$sort_cache = $CACHE->readCache('sort');
$Log_Model = new Log_Model();
if ($sort_cache[$sortid]['pid'] != 0 || empty($sort_cache[$sortid]['children'])) {
$sqlSegment = "and sortid=$sortid";
} else {
$sortids = array_merge(array($sortid), $sort_cache[$sortid]['children']);
$sqlSegment = "and sortid in (" . implode(',', $sortids) . ")";
}
$logs = $Log_Model->getLogsForHome($sqlSegment,1, $num);
return $logs;
}