Discuz手机版套用PC端相关帖子模板,如何实现帖子封面调用,叠加CSS实现效果如下:

调用方法如下:

1、进入Discuz程序目录source\module\forum,打开forum_viewthread.php文件

搜索$post[‘relateitem’]

修改为如下代码,新增相关帖子img地址。

  1. if($post[‘tags’]) {
  2.    $post[‘relateitem’] = getrelateitem($post[‘tags’], $post[‘tid’], $_G[‘setting’][‘relatenum’], $_G[‘setting’][‘relatetime’]);
  3.    foreach($post[‘relateitem’] as $k=>$img)
  4.    {
  5.         $threada= C::t(‘forum_attachment’)->fetch_all_by_id(‘tid’, $img[‘tid’], ‘aid’);
  6.         $threadaid = reset($threada);
  7.         $threadpic = C::t(‘forum_attachment_n’)->fetch_by_aid_uid($threadaid[‘tableid’], $threadaid[‘aid’], $thread[‘authorid’]);
  8.         $thread[‘pic’] = $threadpic[‘attachment’];  
  9.         $post[‘relateitem’][$k][‘img’] = ‘/uploads/2024/’.$thread[‘pic’];
  10.    }
  11. }

复制代码

2、在需要调用帖子封面的位置,通过$var[img]进行调用。

  1. <!–相关推荐–>
  2. <div class=”r_list”>
  3.         <h3 class=”r_list_title” style=”height: 30px;line-height: 30px;”>相关推荐</h3>
  4.                 <ul>
  5.                         <!–{loop $post[‘relateitem’] $var}–>
  6.                         <li><div class=”topic_img” style=”width: 100px;height: 70px;float: left;”><a href=”thread-$var[tid]-1-1.html” target=”_self”><img src=”<font color=”#ff0000″><b>$var[img]</b></font>” alt=”$var[subject]” width=”100px” height=”70px” /></a></div>
  7.                         <a href=”thread-$var[tid]-1-1.html” title=”$var[subject]” target=”_self”>$var[subject]</a></li>
  8.                         <!–{/loop}–>
  9.                 </ul>
  10. </div>
  11. <!—->

复制代码

点赞(0) 打赏

评论列表 共有 0 条评论

暂无评论

微信小程序

微信扫一扫体验

立即
投稿

微信公众账号

微信扫一扫加关注

发表
评论
返回
顶部