Discuz教程网

[插件制作] dz获取门户或博客,或相册文章统计

[复制链接]
authicon 530761333 发表于 2013-7-17 16:33:44 | 显示全部楼层 |阅读模式

  1. function category_get_num($type, $catid) {
  2. global $_G;
  3. if(! in_array($type, array('portal', 'blog', 'album'))) {
  4. return array();
  5. }


  6. loadcache($type.'category');
  7. $category = $_G['cache'][$type.'category'];

  8. $numkey = $type == 'portal' ? 'articles' : 'num';
  9. if(! isset($_G[$type.'category_nums'])) {
  10. $_G[$type.'category_nums'] = array();
  11. $tables = array('portal'=>'portal_category', 'blog'=>'home_blog_category', 'album'=>'home_album_category');
  12. $query = C::t($tables[$type])->fetch_all_numkey($numkey);
  13. foreach ($query as $value) {
  14. $_G[$type.'category_nums'][$value['catid']] = intval($value[$numkey]);
  15. }
  16. }

  17. $nums = $_G[$type.'category_nums'];
  18. $num = intval($nums[$catid]);
  19. if($category[$catid]['children']) {
  20. foreach($category[$catid]['children'] as $id) {
  21. $num += category_get_num($type, $id);
  22. }
  23. }
  24. return $num;
  25. }
复制代码




上一篇:dz论坛在模板里读取所有一级群组分类方法
下一篇:dz批量删除待验证的会员sql方法
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

1314学习网 ( 浙ICP备10214163号 )

GMT+8, 2024-5-20 18:02

Powered by Discuz! X3.4

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表