Discuz!官方免费开源建站系统

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索

[发布] 如何 在 标签 列表页 显示 缩略图?

[复制链接]
berlu 发表于 2012-12-3 15:22:56 | 显示全部楼层 |阅读模式
如何 在 标签 列表页 显示 缩略图?
  1. <?php

  2. /**
  3. *      [Discuz!] (C)2001-2099 Comsenz Inc.
  4. *      This is NOT a freeware, use is subject to license terms
  5. *
  6. *      $Id: misc_tag.php 28214 2012-02-24 06:38:56Z zhengqingpeng $
  7. */

  8. if(!defined('IN_DISCUZ')) {
  9.         exit('Access Denied');
  10. }

  11. require_once libfile('function/post');


  12. $id = intval($_GET['id']);
  13. $type = trim($_GET['type']);
  14. $name = trim($_GET['name']);
  15. $page = intval($_GET['page']);
  16. if($type == 'countitem') {
  17.         $num = 0;
  18.         if($id) {
  19.                 $num = C::t('common_tagitem')->count_by_tagid($id);
  20.         }
  21.         include_once template('tag/tag');
  22.         exit();
  23. }
  24. $taglang = lang('tag/template', 'tag');
  25. if($id || $name) {

  26.         $tpp = 20;
  27.         $page = max(1, intval($page));
  28.         $start_limit = ($page - 1) * $tpp;
  29.         if($id) {
  30.                 $tag = C::t('common_tag')->fetch_info($id);
  31.         } else {
  32.                 if(!preg_match('/^([\x7f-\xff_-]|\w|\s)+$/', $name) || strlen($name) > 20) {
  33.                         showmessage('parameters_error');
  34.                 }
  35.                 $name = addslashes($name);
  36.                 $tag = C::t('common_tag')->fetch_info(0, $name);
  37.         }

  38.         if($tag['status'] == 1) {
  39.                 showmessage('tag_closed');
  40.         }
  41.         $tagname = $tag['tagname'];
  42.         $id = $tag['tagid'];
  43.         $searchtagname = $name;
  44.         $navtitle = $tagname ? $taglang.' - '.$tagname : $taglang;
  45.         $metakeywords = $tagname ? $taglang.' - '.$tagname : $taglang;
  46.         $metadescription = $tagname ? $taglang.' - '.$tagname : $taglang;


  47.         $showtype = '';
  48.         $count = '';
  49.         $summarylen = 300;

  50.         if($type == 'thread') {
  51.                 $showtype = 'thread';
  52.                 $tidarray = $threadlist = array();
  53.                 $count = C::t('common_tagitem')->select($id, 0, 'tid', '', '', 0, 0, 0, 1);
  54.                 if($count) {
  55.                         $query = C::t('common_tagitem')->select($id, 0, 'tid', '', '', $start_limit, $tpp);
  56.                         foreach($query as $result) {
  57.                                 $tidarray[$result['itemid']] = $result['itemid'];
  58.                         }
  59.                         $threadlist = getthreadsbytids($tidarray);
  60.                         $multipage = multi($count, $tpp, $page, "misc.php?mod=tag&id=$tag[tagid]&type=thread");
  61.                 }
  62.         } elseif($type == 'blog') {
  63.                 $showtype = 'blog';
  64.                 $blogidarray = $bloglist = array();
  65.                 $count = C::t('common_tagitem')->select($id, 0, 'blogid', '', '', 0, 0, 0, 1);
  66.                 if($count) {
  67.                         $query = C::t('common_tagitem')->select($id, 0, 'blogid', '', '', $start_limit, $tpp);
  68.                         foreach($query as $result) {
  69.                                 $blogidarray[$result['itemid']] = $result['itemid'];
  70.                         }
  71.                         $bloglist = getblogbyid($blogidarray);

  72.                         $multipage = multi($count, $tpp, $page, "misc.php?mod=tag&id=$tag[tagid]&type=blog");
  73.                 }
  74.         } else {
  75.                 $shownum = 20;

  76.                 $tidarray = $threadlist = array();
  77.                 $query = C::t('common_tagitem')->select($id, 0, 'tid', '', '', $shownum);
  78.                 foreach($query as $result) {
  79.                         $tidarray[$result['itemid']] = $result['itemid'];
  80.                 }
  81.                 $threadlist = getthreadsbytids($tidarray);

  82.                 if(helper_access::check_module('blog')) {
  83.                         $blogidarray = $bloglist = array();
  84.                         $query = C::t('common_tagitem')->select($id, 0, 'blogid', '', '', $shownum);
  85.                         foreach($query as $result) {
  86.                                 $blogidarray[$result['itemid']] = $result['itemid'];
  87.                         }
  88.                         $bloglist = getblogbyid($blogidarray);
  89.                 }

  90.         }

  91.         include_once template('tag/tagitem');

  92. } else {
  93.         $navtitle = $metakeywords = $metadescription = $taglang;
  94.         $viewthreadtags = 100;
  95.         $tagarray = array();
  96.         $query = C::t('common_tag')->fetch_all_by_status(0, '', $viewthreadtags);
  97.         foreach($query as $result) {
  98.                 $tagarray[] = $result;
  99.         }
  100.         include_once template('tag/tag');
  101. }

  102. function getthreadsbytids($tidarray) {
  103.         global $_G;

  104.         $threadlist = array();
  105.         if(!empty($tidarray)) {
  106.                 loadcache('forums');
  107.                 include_once libfile('function_misc', 'function');
  108.                 $fids = array();
  109.                 foreach(C::t('forum_thread')->fetch_all_by_tid($tidarray) as $result) {
  110.                         if(!isset($_G['cache']['forums'][$result['fid']]['name'])) {
  111.                                 $fids[$result['fid']] = $result['tid'];
  112.                         } else {
  113.                                 $result['name'] = $_G['cache']['forums'][$result['fid']]['name'];
  114.                         }
  115.                         $threadlist[$result['tid']] = procthread($result);
  116.                 }
  117.                 if(!empty($fids)) {
  118.                         foreach(C::t('forum_forum')->fetch_all_by_fid(array_keys($fids)) as $fid => $forum) {
  119.                                 $_G['cache']['forums'][$fid]['forumname'] = $forum['name'];
  120.                                 $threadlist[$fids[$fid]]['forumname'] = $forum['name'];
  121.                         }
  122.                 }
  123.         }
  124.         return $threadlist;
  125. }

  126. function getblogbyid($blogidarray) {
  127.         global $_G;

  128.         $bloglist = array();
  129.         if(!empty($blogidarray)) {
  130.                 $data_blog = C::t('home_blog')->fetch_all($blogidarray, 'dateline', 'DESC');
  131.                 $data_blogfield = C::t('home_blogfield')->fetch_all($blogidarray);

  132.                 require_once libfile('function/spacecp');
  133.                 require_once libfile('function/home');
  134.                 $classarr = array();
  135.                 foreach($data_blog as $curblogid => $result) {
  136.                         $result = array_merge($result, (array)$data_blogfield[$curblogid]);
  137.                         $result['dateline'] = dgmdate($result['dateline']);
  138.                         $classarr = getclassarr($result['uid']);
  139.                         $result['classname'] = $classarr[$result[classid]]['classname'];
  140.                         if($result['friend'] == 4) {
  141.                                 $result['message'] = $result['pic'] = '';
  142.                         } else {
  143.                                 $result['message'] = getstr($result['message'], $summarylen, 0, 0, 0, -1);
  144.                         }
  145.                         $result['message'] = preg_replace("/&[a-z]+\;/i", '', $result['message']);
  146.                         if($result['pic']) {
  147.                                 $result['pic'] = pic_cover_get($result['pic'], $result['picflag']);
  148.                         }
  149.                         $bloglist[] = $result;
  150.                 }
  151.         }
  152.         return $bloglist;
  153. }


  154. ?>
复制代码
怎么顺利加入?

  1. function getthreadcover($tid, $cover = 0, $getfilename = 0) {
  2.         global $_G;
  3.         if(empty($tid)) {
  4.                 return '';
  5.         }
  6.         $coverpath = '';
  7.         $covername = 'threadcover/'.substr(md5($tid), 0, 2).'/'.substr(md5($tid), 2, 2).'/'.$tid.'.jpg';
  8.         if($getfilename) {
  9.                 return $covername;
  10.         }
  11.         if($cover) {
  12.                 $coverpath = ($cover < 0 ? $_G['setting']['ftp']['attachurl'] : $_G['setting']['attachurl']).'forum/'.$covername;
  13.         }
  14.         return $coverpath;
  15. }
复制代码
4535 发表于 2012-12-3 16:15:10 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
回复

使用道具 举报

ringringtt 发表于 2012-12-3 18:04:21 | 显示全部楼层
让我一次回复个够。。。。。。。。。。。。
回复

使用道具 举报

ringringtt 发表于 2012-12-3 18:04:47 | 显示全部楼层
让我一次回复个够。。。。。。。。。。。。
回复

使用道具 举报

ringringtt 发表于 2012-12-3 18:05:28 | 显示全部楼层
让我一次回复个够。。。。。。。。。。。。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|Discuz! 官方站 ( 皖ICP备16010102号 )star

GMT+8, 2024-10-3 08:25 , Processed in 0.115327 second(s), 17 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

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