请选择 进入手机版 | 继续访问电脑版

UESOHO

discuz列表页多图/内容/收藏/点赞展示

admin 发表于 7-6 14:27:48 | 0 条回复 | 1031 次浏览

找到文件\source\module\forum\forum_forumdisplay.php
搜索(大约812行)$threadids[$threadindex] = $thread['tid'];
添加
  1. include_once libfile('function/post');
  2. include_once libfile('function/attachment');
  3. $thread['post'] = C::t('forum_post')->fetch_all_by_tid_position($thread['posttableid'],$thread['tid'],1);
  4. $thread['post'] = array_shift($thread['post']);
  5. $thread['preview'] = messagecutstr($thread['post']['message'], 200);//控制字符
  6. $attachments = C::t('forum_attachment_n')->fetch_all_by_id('tid:'.$thread['post']['tid'], 'pid', $thread['post']['pid']);
  7. $attachs = $imgattachs = array();
  8. foreach(C::t('forum_attachment')->fetch_all_by_id('pid', $thread['post']['pid'], 'aid') as $attach) {
  9. $attach = array_merge($attach, $attachments[$attach['aid']]);
  10. $attach['filenametitle'] = $attach['filename'];
  11. $attach['ext'] = fileext($attach['filename']);
  12. getattach_row($attach, $attachs, $imgattachs);
  13. }
  14. $thread['attachments'] = $imgattachs;
复制代码

模板文件位置/template/default/touch/forum/forumdisplay.htm
调用帖子文字内容
  1. <p>$thread['preview']</p>
复制代码

调用附件图片
  1. {if $thread['attachment'] == 2 && $thread['attachments']['used']}
  2. <p class="attachmentimg">
  3. {loop $thread['attachments']['used'] $keyimg $valimg}
  4. <a class="attachmentimg attachmentimg_$i" href="$valimg['url']/$valimg['attachment']"><img src="$valimg['url']/$valimg['attachment']" width=$valimg['width'] height=$valimg['width'] /></a>
  5. {/loop}
  6. </p>
  7. {/if}
复制代码
说明:
参看\source\function\function_post.php中的getattach_row函数(在文件的第61行)
首页要确定$thread['attachment'] == 2和数组$thread['attachments']['used']为真,才可以运行以下代码。
循环搜索数组$thread['attachments']['used']
在循环内数组$valimg[]可以调用表pre_forum_attachment_2中的键值(参看:Discuz! X3 数据字典 DZ数据表结构)

触摸版:图片调用,如果有则调用,如果没有则不调用
  1. {if $thread['attachment'] == 2}
  2. {eval $table='forum_attachment_'.substr($thread['tid'], -1);}
  3. {eval $thread['aid'] = DB::result_first("SELECT aid FROM ".DB::table($table)." WHERE tid='$thread[tid]' AND isimage!='0'");}
  4. {/if}
  5. //以下三种形式,前面必须有以上的几行代码,或者用自己的方法把它们结合到一起
  6. //形式一
  7. {if $thread['aid']}
  8. <img alt="" src="{eval echo(getforumimg($thread['aid'],1,120,120))}" />
  9. {/if}
  10. //形式二
  11. {if $thread['aid']}
  12. <img alt="" src="{eval echo(getforumimg($thread['aid']))}" />
  13. {/if}
  14. //形式三
  15. {if $thread['aid']}
  16. {eval $abc=getforumimg($thread['aid'])}
  17. <img src="$abc" alt="" />
  18. {/if}
复制代码

多图
  1. f $thread['attachment'] == 2}
  2. {eval $table='forum_attachment_'.substr($thread['tid'], -1);}
  3. {eval $thread['attachmentimg'] = DB::fetch_all("SELECT * FROM ".DB::table($table)." WHERE tid='$thread[tid]' AND isimage!='0'");}
  4. {loop $thread['attachmentimg'] $keyimg $valimg}
  5. <a class="attachmentimg attachmentimg_$i" href="data/attachment/forum/$valimg['attachment']"><img src="data/attachment/forum/$valimg['attachment']" /></a>
  6. {/loop}
  7. {/if}
复制代码

收藏
  1. {if !IS_ROBOT && !$_G['forum_thread']['archiveid']}
  2. {if $post['invisible'] == 0}
  3. <a href="home.php?mod=spacecp&ac=favorite&type=thread&id=$thread[tid]&formhash={FORMHASH}" id="k_favorite" onclick="showWindow(this.id, this.href, 'get', 0);" title="{lang fav_thread}"><i><img src="{IMGDIR}/fav.gif" alt="{lang thread_favorite}" /><span id="favoritenumber">$thread['favtimes']</span></i></a>
  4. {/if}
  5. {/if}
复制代码

点赞
  1. {if !empty($_G['setting']['recommendthread']['addtext'])}
  2. <a id="recommend_add" href="forum.php?mod=misc&action=recommend&do=add&tid=$thread['tid']&hash={FORMHASH}" {if $thread['tid']}onclick="ajaxmenu(this, 3000, 1, 0, '43', 'recommendupdate({$_G['group']['allowrecommend']})');return false;"{else} onclick="showWindow('login', this.href)"{/if}><i><img src="{IMGDIR}/rec_add.gif" alt="$_G['setting']['recommendthread'][addtext]" />$_G['setting']['recommendthread'][addtext]<span id="recommendv_add">$thread['recommend_add']</span></i></a>
  3. {/if}
复制代码

分享
  1. <a href="home.php?mod=spacecp&ac=share&type=thread&id=$thread[tid]" id="k_share" onclick="showWindow(this.id, this.href, 'get', 0);"><i><img src="{IMGDIR}/oshr.png" alt="{lang thread_share}" />{lang thread_share}<span id="sharenumber">{$thread['sharetimes']}</span></i></a>
复制代码
前提条件:开启QQ互联功能插件

回复 道具 举报

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

UESOHO/津ICP备11001501号-4 Powered by Discuz!

top