最新最全的移动资源,海量教程攻略!

网站首页 > 技术支持 > discuz > discuz使用教程 > disc最新uz 首页调用帖子列表带分页

disc最新uz 首页调用帖子列表带分页

作者: 资源猫 时间: 2020-03-03 17:45:38 人气: 5

前面发了一篇门户首页调用文章列表,这里发下调用帖子列表的代码。
这个代码放到门户首页index.htm模板中
!--{eval require './source/function/function_post.php';}--
!--{eval require './config/config_global.php';}--
!--{eval $prefix=$_config['db']['1']['tablepre'] }--
!--{eval $pagesize = 10;}--
!--{eval $amount=0;}--
!--{eval $res = mysql_query( SELECT COUNT(*) as count FROM .$prefix. forum_thread t1 LEFT OUTER JOIN  .$prefix. forum_threadimage t3 ON t1.tid = t3.tid WHERE t1.displayorder - 1 AND t3.attachment '' }--
!--{eval while($re=mysql_fetch_array($res)) $amount=$re['count']}--
!--{eval $pagecount = $amount ? (($amount $pagesize) ? 1 : (($amount % $pagesize) ? ((int)($amount / $pagesize) + 1) : ($amount / $pagesize))) : 0; }--
!--{eval $page = !empty($_G['gp_page']) ? max(1, intval($_G['gp_page'])) : 1;}--
!--{eval $page = $page $pagecount ? 1 : $page;}--
!--{eval $startlimit = ($page - 1) * $pagesize;}--
!--{eval $multipage = multi($amount, $pagesize, $page, 'portal.php?', $pagecount);}--
!--{eval $res = mysql_query( SELECT t1.tid,t1.fid,t2.`name`,t1.author,t1.authorid,t1.`subject`,t4.message,t1.views,t1.replies,from_unixtime(t1.dateline) as dateline,t3.attachment FROM .$prefix. forum_thread t1 LEFT OUTER JOIN  .$prefix. forum_forum t2 ON t1.fid = t2.fid LEFT OUTER JOIN  .$prefix. forum_threadimage t3 ON t1.tid = t3.tid LEFT OUTER JOIN  .$prefix. forum_post t4 ON t1.tid = t4.tid WHERE t1.displayorder - 1 AND t3.attachment '' AND t4.`first` 0 ORDER BY t1.dateline DESC LIMIT $startlimit, $pagesize }--
复制代码
调用列表开始:
!--{eval while($re1=mysql_fetch_array($res)) {}--
a href= forum.php?mod=viewthread tid=$re1[tid] !--帖子链接--
!--{if $re1[attachment]}-- !--如果图片附件存在--
img src= $_G[setting][attachurl]forum/$re1[attachment] width= 120 height= auto !--本地存储图片附件路径--
!--{/if}--
/a
h3 a href= forum.php?mod=viewthread tid=$re1[tid] title= $article[title] $re1[subject] /a /h3 !--帖子链接、标题--
p !--{eval echo messagecutstr($re1['message'],150)}-- /p !--帖子摘要150字符--
a href= forum.php?mod=forumdisplay fid=$re1[fid] >
em >
a href= home.php?mod=space uid=$re1[authorid] >
em >
span >
span >
span >
!--{eval }}--
div >
复制代码
以上就可以成功调用了。
说明:
以上代码调用的是含有图片附件的主题,如果想要调用所有,删掉第一步代码最后的 AND t3.attachment,可调用到无图片附件帖。
!--{eval $pagesize = 10;}-- 是每10条分页。
我这里测试的结果是共有8页,不知道怎么能改变调用总数。
----------------------------------------------------------------------
另一个代码,这个好像也没控制住总数,这是调用全部帖子:
!--{eval require './source/function/function_post.php';}--
!--{eval $pagesize = 9;}--
!--{eval $amount=0;}--
!--{eval $res = mysql_query( select count(*) as count from pre_forum_post where fid in(select fid from pre_forum_forum where status=1 and type='forum') and bbcodeoff -1 }--
!--{eval while($re=mysql_fetch_array($res)) $amount=$re['count']}--
!--{eval $pagecount = $amount ? (($amount $pagesize) ? 1 : (($amount % $pagesize) ? ((int)($amount / $pagesize) + 1) : ($amount / $pagesize))) : 0; }--
!--{eval $page = !empty($_G['gp_page']) ? max(1, intval($_G['gp_page'])) : 1;}--
!--{eval $page = $page $pagecount ? 1 : $page;}--
!--{eval $startlimit = ($page - 1) * $pagesize;}--
!--{eval $multipage = multi($amount, $pagesize, $page, 'portal.php?', $pagecount);}--
!--{eval $res = mysql_query( select t1.tid,t1.views,t1.author,t1.subject,FROM_UNIXTIME(t1.dateline,'%Y') as year,FROM_UNIXTIME(t1.dateline,'%m') as month,FROM_UNIXTIME(t1.dateline,'%d') as day,t2.message,t3.attachment,t4.name,t4.fid from pre_forum_thread t1 left join pre_forum_post t2 on t1.tid=t2.tid left join pre_forum_threadimage t3 on t1.tid=t3.tid left join pre_forum_forum t4 on t1.fid=t4.fid where t1.displayorder -1 and t3.attachment ' ' order by t1.dateline desc LIMIT $startlimit, $pagesize }--
!--{eval $src= }--
!--{eval while($re1=mysql_fetch_array($res)) {}--  
div >
      div >
            span >
                  a href= forum.php?mod=viewthread tid=$re1['tid'] title= $re1['subject']
                      span 'month']月 /span
                      span 'day'] /span
                      span 'year'] /span
                  /a
            /span
            span >
                  a href= forum.php?mod=viewthread tid=$re1['tid'] title= $re1['subject'] 'views'] /a
                  a href= forum.php?mod=viewthread tid=$re1['tid'] title= $re1['subject'] Comment /a
            /span
            span >
                  span by br / $re1['author'] /span
            /span
      /div
  div >
    div >
          a href= forum.php?mod=viewthread tid=$re1['tid'] title= $re1['subject'] img src= data/attachment/forum/$re1['attachment'] / /a
    /div
    h3 >
          a href= forum.php?mod=viewthread tid=$re1['tid'] title= $re1['subject'] $re1['subject'] /a
    /h3
    div 'fid'] $re1['name'] /a /div
    div >
          !--{eval $src=messagecutstr($re1['message'],300)}--
          p $src /p
    /div
  /div
/div
!--{eval }}--
div "data/attachment/block/8a/8a86afb33a52e48246ec7b90eeddde25.jpg" alt="帝国CMS内核新版《做菜网》食谱网站源码 带手机版" />
帝国CMS内核新版《做菜网》食谱网站源码 带
YzmCMS轻量级开源CMS v3.7.1
YzmCMS轻量级开源CMS v3.7.1
影子淘客ThinkPHP优惠券系统支持微信公众号以及淘口令
影子淘客ThinkPHP优惠券系统支持微信公众号
帝国CMS内核92GAME仿《明星网》娱乐新闻资讯网站源码
帝国CMS内核92GAME仿《明星网》娱乐新闻资
wordpress蓝白色经典两栏博客主题:lantu
wordpress蓝白色经典两栏博客主题:lantu
织梦DEDECMS职业健康企业网站源码带手机版
织梦DEDECMS职业健康企业网站源码带手机版

感谢访问资源猫吧,本站所有资源均来自互联网或用户分享,如您发现本站存在侵权或违规内容,请来邮件告知我们! 资源分享/侵权下架/商务合作联系邮箱:qiazou77ziyuan@126.com