- function category_get_num($type, $catid) {
- global $_G;
- if(! in_array($type, array('portal', 'blog', 'album'))) {
- return array();
- }
- loadcache($type.'category');
- $category = $_G['cache'][$type.'category'];
- $numkey = $type == 'portal' ? 'articles' : 'num';
- if(! isset($_G[$type.'category_nums'])) {
- $_G[$type.'category_nums'] = array();
- $tables = array('portal'=>'portal_category', 'blog'=>'home_blog_category', 'album'=>'home_album_category');
- $query = C::t($tables[$type])->fetch_all_numkey($numkey);
- foreach ($query as $value) {
- $_G[$type.'category_nums'][$value['catid']] = intval($value[$numkey]);
- }
- }
- $nums = $_G[$type.'category_nums'];
- $num = intval($nums[$catid]);
- if($category[$catid]['children']) {
- foreach($category[$catid]['children'] as $id) {
- $num += category_get_num($type, $id);
- }
- }
- return $num;
- }
复制代码
|
上一篇: dz论坛在模板里读取所有一级群组分类方法下一篇: dz批量删除待验证的会员sql方法
|