时间:2021-05-02
前面发了一篇门户首页调用文章列表,这里发下调用帖子列表的代码。 这个代码放到门户首页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]" 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><!--帖子发表时间--><span class="article-info-num y"><i></i>$re1[replies]</span><!--帖子评论数--><span class="article-info-view y"><i></i>$re1[views]</span><!--帖子点击数--><!--{eval }}--><div class="pages cl">$multipage</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 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>
声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。
在destoon开发中有时候我们需要调用论坛的帖子,但是带有图片的帖子该怎么调用出来呢,本文就来实例展示一个可以调用discuz论坛带图片的帖子的方法:标签代码
discuz帖子正文下方有一组自动推荐的相关帖子,其调用代码为{langrelated_thread}•$var[subject]复制代码
discuz如何在diy帖子列表模块调用随机文章,关于随机文章到底是好还是坏一直是很多做SEO一直在争论的问题,在这里博主认为,其实页面增加小部分随机文章链接对
discuz论坛的分区默认没有伪静态设置,下面总结下分区+列表、帖子页面包屑伪静态。方法:1.分区伪静态打开当前模板风格中forum/discuz.htm,也就
淘帖淘的是帖子,和帖子列表页调用缩略图是一样的。这里示例调用最多10张图。淘帖列表页模板是collection_view.htm,默认模板是在第231行()之后