花魁直播高品质美女在线视频互动社区 - 花魁直播官方版

 歡迎來到素材無憂網(wǎng),按 + 收藏我們
登錄 注冊 退出 找回密碼

discuz 首頁調(diào)用帖子列表帶分頁

時(shí)間: 2019-05-24 11:57 閱讀: 作者:素材無憂網(wǎng)

前面發(fā)了一篇門戶首頁調(diào)用文章列表,這里發(fā)下調(diào)用帖子列表的代碼。 這個(gè)代碼放到門戶首頁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");}-->
復(fù)制代碼
調(diào)用列表開始:
<!--{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"><!--本地存儲(chǔ)圖片附件路徑-->
<!--{/if}-->
</a>
<h3><a href="forum.php?mod=viewthread&tid=$re1[tid]" title="$article[title]">$re1[subject]</a></h3><!--帖子鏈接、標(biāo)題-->
<p><!--{eval echo messagecutstr($re1['message'],150)}--></p><!--帖子摘要150字符-->
<a href="forum.php?mod=forumdisplay&fid=$re1[fid]" class="article-info-cat z">$re1[name]</a><!--板塊鏈接、板塊名-->
<em class="sprit z">/</em>
<a href="home.php?mod=space&uid=$re1[authorid]" class="z">$re1[author]</a><!--帖子作者鏈接、作者用戶名-->
<em class="sprit z">/</em>
<span class="article-info-date z">$re1[dateline]</span><!--帖子發(fā)表時(shí)間-->
<span class="article-info-num y"><i></i>$re1[replies]</span><!--帖子評論數(shù)-->
<span class="article-info-view y"><i></i>$re1[views]</span><!--帖子點(diǎn)擊數(shù)-->
<!--{eval }}-->
<div class="pages cl">$multipage</div><!--帖子列表分頁-->
復(fù)制代碼
以上就可以成功調(diào)用了。 說明: 以上代碼調(diào)用的是含有圖片附件的主題,如果想要調(diào)用所有,刪掉第一步代碼最后的 AND t3.attachment,可調(diào)用到無圖片附件帖。 <!--{eval $pagesize = 10;}-->是每10條分頁。 我這里測試的結(jié)果是共有8頁,不知道怎么能改變調(diào)用總數(shù)。   ---------------------------------------------------------------------- 另一個(gè)代碼,這個(gè)好像也沒控制住總數(shù),這是調(diào)用全部帖子:
<!--{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 class="page-container">
        <div class="postmetadata">
                <span class="meta-date">
                        <a href="forum.php?mod=viewthread&&tid=$re1['tid']" title="$re1['subject']">
                                <span class="month">$re1['month']月</span>
                                <span class="day">$re1['day']</span>
                                <span class="year">$re1['year']</span>
                        </a>
                </span>
                <span class="meta-comments">
                        <a href="forum.php?mod=viewthread&&tid=$re1['tid']" title="$re1['subject']" class="comments-count">$re1['views']</a>
                        <a href="forum.php?mod=viewthread&&tid=$re1['tid']" title="$re1['subject']">Comment</a>
                </span>
                <span class="meta-author">
                        <span>by<br />$re1['author']</span>
                </span>
        </div>
  <div class="post-contents">
    <div class="thumbnail">
            <a href="forum.php?mod=viewthread&&tid=$re1['tid']" title="$re1['subject']"><img src="data/attachment/forum/$re1['attachment']"/></a>
    </div>
    <h3 class="entry-title">
            <a href="forum.php?mod=viewthread&&tid=$re1['tid']" title="$re1['subject']">$re1['subject']</a>
    </h3>
    <div class="post-category">來自于<a href="forum.php?mod=forumdisplay&fid=$re1['fid']">$re1['name']</a></div>
    <div class="post-content">
            <!--{eval $src=messagecutstr($re1['message'],300)}--> 
            <p>$src</p>
    </div>
  </div>
</div>
<!--{eval }}--> 
<div class="pags c1"><div id="pag"> $multipage </div></div>

版權(quán)聲明: 本站資源均來自互聯(lián)網(wǎng)或會(huì)員發(fā)布,如果侵犯了您的權(quán)益請與我們聯(lián)系,我們將在24小時(shí)內(nèi)刪除!謝謝!

轉(zhuǎn)載請注明: discuz 首頁調(diào)用帖子列表帶分頁

標(biāo)簽:  
相關(guān)文章
模板推薦