加入收藏 | 设为首页 | 会员中心 | 我要投稿 云计算网_泰州站长网 (http://www.0523zz.com/)- 视觉智能、AI应用、CDN、行业物联网、智能数字人!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

discuz个人空间主题列表 图片模式达成方法

发布时间:2021-11-30 18:07:44 所属栏目:PHP教程 来源:互联网
导读:如果需要实现该呈现方式,我们需要首先了解discuz封面图片存储原理: discuz没有将主题列表封面路径存在数据表中,只是在pre_forum_thread表中存了一个cover标识。然后用getthreadcover 函数调取,diy调用的图片也会产生缩略图,可以设置缩略图的质量。 封面

如果需要实现该呈现方式,我们需要首先了解discuz封面图片存储原理:
discuz没有将主题列表封面路径存在数据表中,只是在pre_forum_thread表中存了一个cover标识。然后用getthreadcover 函数调取,diy调用的图片也会产生缩略图,可以设置缩略图的质量。
封面图片存储路径格式:data/attachment/forum/threadcover/43/ec/81.jpg
01
getthreadcover 函数:
02
function getthreadcover($tid, $cover = 0, $getfilename = 0) {
03
  global $_G;
04
  if(empty($tid)) {
05
    return '';
06
  }
07
  $coverpath = '';
08
  $covername = 'threadcover/'.substr(md5($tid), 0, 2).'/'.substr(md5($tid), 2, 2).'/'.$tid.'.jpg';
09
  if($getfilename) {
10
    return $covername;
11
  }
12
  if($cover) {
13
    $coverpath = ($cover < 0 ? $_G['setting']['ftp']['attachurl'] : $_G['setting']['attachurl']).'forum/'.$covername;
14
  }
15
  return $coverpath;
16
}
 
文件路径:/source/function/function_forum.php
复制代码
实现方法:
修改:/source/language/home/lang_template.php
添加like 喜欢或查看
 
修改:/template/default/home/space_thread.htm
处理封面图:
1
{eval
2
  $covername = 'threadcover/'.substr(md5($thread[tid]), 0, 2).'/'.substr(md5($thread[tid]), 2, 2).'/'.$thread[tid].'.jpg';
3
   
4
  $coverpath = ($cover < 0 ? $_G['setting']['ftp']['attachurl'] : $_G['setting']['attachurl']).'forum/'.$covername;
5
}
 
 
图片列表
01
<li style="width: 227px;  left: 0px; top: 0px;float:left;">
02
  <div class="c cl">
03
  <a class="z" title="$thread[subject]" onclick="atarget(this)" href="forum.php?mod=viewthread&tid=$thread[tid]">
04
  <img width="203" alt="$thread[subject]" src="{eval echo $coverpath;}">
05
  </a>
06
  </div>
07
  <h3 class="xw0">
08
 
09
  <a href="forum.php?mod=viewthread&tid=$thread[tid]" onclick="atarget(this)" target="_blank" {if $thread['displayorder'] == -1}class="recy"{/if}>$thread[subject]</a>
10
   
11
  </h3>
12
  <div class="auth cl">
13
  <cite class="xg1 y">
14
  {lang like}: <em>$thread[views]</em>   {lang reply}: <a title="0 回复" href="forum.php?mod=viewthread&tid=$thread[tid]">$thread[replies]</a>
15
  </cite>
16
  <a href="home.php?mod=space&uid=$thread[authorid]" target="_blank">$thread[author]</a>$thread[dateline]</div>
17
</li>
 

(编辑:云计算网_泰州站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    热点阅读