本帖最后由 史前科学家 于 2009-12-8 21:06 编辑
我想使用ss模块sql高级方式调用论坛图片和文字等等信息,之前我采用的是循环嵌套的方式得到这个图文混排页面http:www.ideame.cn,但是我觉得这种方式效率不高,而且我还想改进一些功能,所以换了种方法,
sql语句如下
SELECT cdb_attachments.* , cdb_posts.author, cdb_posts.subject, cdb_posts.message, cdb_posts.avers, cdb_posts.averu, cdb_posts.alla
FROM a1013184444.cdb_attachments INNER JOIN $value on cdb_attachments.tid=$value[tid]
where isimage=1 and $value[first]=1
GROUP BY cdb_attachments.tid
ORDER BY cdb_posts.dateline DESC
这个查询我不过多的介绍,里面有一些我自己建的字段,看的人不要惊讶为什么自己的数据库为什么没有这些字段
得到ss的模块调用代码
<!--{block name="bbsthread" parameter="sql/SELECT%20cdb_attachments.%2A%20%2C%20cdb_posts.author%2C%20cdb_posts.subject%2C%20cdb_posts.message%2C%20cdb_posts.avers%2C%20cdb_posts.averu%2C%20cdb_posts.alla%0D%0AFROM%20%20%20a1013184444.cdb_attachments%20%20%20%20INNER%20JOIN%20%20%24value%20on%20%20%20cdb_attachments.tid%3D%24value%5Btid%5D%20%20%0D%0Awhere%20isimage%3D1%20%20%20and%20%24value%5Bfirst%5D%3D1%0D%0AGROUP%20BY%20cdb_attachments.tid%0D%0AORDER%20BY%20%20cdb_posts.dateline%20%20DESC/perpage/10/cachename/newlist2/tpl/data"}--><!--newlist2-->
把这个查询放到我自己建的一个频道模板里面channel_test.html.php里面
注意这个模板修改修改自bbs_forumdisplay.html.php ,目的是想让ss列表页图文并茂的显示,代码如下- <?exit?>
- <!--{template header}-->
- <!--{eval $ads = getad('system', 'bbs', '1'); }-->
- <!--{if !empty($ads['pageheadad']) }-->
- <div class="ad_header">$ads[pageheadad]</div>
- <!--{/if}-->
- </div><!--header end-->
- <div id="nav">
- <div class="main_nav">
- <ul>
- <!--{if empty($_SCONFIG['defaultchannel'])}-->
- <li><a href="{S_URL}/index.php">首页</a></li>
- <!--{/if}-->
-
- <!--{loop $channels['menus'] $key $value}-->
- <li <!--{if $key == 'bbs' }--> class="current"<!--{/if}-->><a href="$value[url]">$value[name]</a></li>
- <!--{/loop}-->
-
- </ul>
- </div>
- <ul class="ext_nav clearfix">
- <!--{eval $dot = '|'}-->
- <!--{eval $total = count($forumarr)}-->
- <!--{eval $i = 1;}-->
- <li><a href="http://www.ideame.cn">全部</a><!--{if $total != $i}--> $dot <!--{/if}--></li>
- <!--{loop $forumarr $value}-->
-
- <li><a href="http://www.ideame.cn/?action-forumdisplay-fid-$value[fid]">$value[name]</a><!--{if $total != $i}--> $dot <!--{/if}--></li>
- <!--{eval $i++;}-->
- <!--{/loop}-->
- <li>                                                            </li>
- <div class="searchbar">
- <spacer type="horizontal" size=1000>
- <form method="post" action="bbs/search.php?searchsubmit=yes" onSubmit="this.target='_blank';">
- <input type="hidden" name="searchsubmit" value="yes">
- <input class="input_kuang" type="text" name="srchtxt" value="">
- <input class="input_search" type="submit" value="搜索" name="searchbtn"/>
- </form>
- </div>
- </ul>
- </div><!--nav end-->
- <div class="column">
- <div class="col1">
- <div class="global_module margin_bot10 bg_fff">
- <div class="global_module3_caption">
- <h3>
- <em style="float:right; padding:0 5px 0 0;">
- <a href="{B_URL}" title="转至论坛" class="vote" target="_blank">转至论坛</a>
- </em>
- 您的位置:<a href="{S_URL}/">$_SCONFIG[sitename]</a>
- <!--{loop $guidearr $value}-->
- <a href="$value[url]"></a>
- <!--{/loop}--></h3></div>
-
-
-
-
-
- <!--根分类最新帖子列表-->
- <!--{if $forum['type'] != 'group'}-->
-
- <!--{block name="bbsthread" parameter="sql/SELECT%20cdb_attachments.%2A%20%2Ccdb_posts.author%2Ccdb_posts.subject%2Ccdb_posts.message%2Ccdb_posts.avers%2Ccdb_posts.averu%2Ccdb_posts.alla%0D%0AFROM%20%20%20a1013184444.cdb_attachments%20%20%20%20INNER%20JOIN%20%20a1013184444.cdb_posts%20on%20%20%20cdb_attachments.tid%3Dcdb_posts.tid%20%20%0D%0Awhere%20isimage%3D1%20%20%20and%20cdb_posts.first%3D1%0D%0AGROUP%20BY%20cdb_attachments.tid%0D%0AORDER%20BY%20%20cdb_posts.dateline%20%20DESC/*/$fid/showdetail/1/messagelen/160/messagedot/1/cachetime/44400/perpage/10/cachename/newlist1/tpl/data"}--><!--newlist1-->
-
-
-
-
-
- <!--{if $_SBLOCK['newlist1']}-->
-
- <ul class="news_list">
-
-
-
-
-
-
- <!--{loop $_SBLOCK['newlist1'] $value}-->
-
-
-
-
-
-
- <li>
-
-
-
-
- <table width="80%" border="0">
-
- <tr>
-
- <td rowspan="2" width="10%"><img src = "http://www.ideame.cn/templates/default/images/title.png" ></td>
- <td><h4><a href="$value[url]"><font size="4">$value[subject]</font></a></h4></td>
-
- </tr>
- <tr>
-
- <td > <p class="news_list_caption"><a href="#uid/$value[authorid]#">$value[author]</a> 发表于:<font size="3" color="#00A600"><b>#date("Y-m-d", $value["dateline"])#</b></font> 回复:$value[replies]</p></td>
-
- </tr>
-
-
-
- </table>
-
- </html>
-
-
-
-
-
-
-
-
-
-
- <script language="javascript">
- <!--
- function ReImgSize(){
- for (i=0;i<document.images.length;i++)
- {
- if (document.all){
- if (document.images[i].width>500)
- {
- if(document.images[i].style.width!="100%"){
- document.images[i].style.width = "100%";
- document.images[i].border = "0";
- document.images[i].outerHTML=’<a href="’+document.images[i].src+’" target="_blank" title="在新窗口打开图片">’+document.images[i].outerHTML+’</a>’
- }
- }
- }
- else{
- if (document.images[i].width>400) {
- document.images[i].title="在新窗口打开图片"
- document.images[i].style.cursor="pointer"
- document.images[i].onclick=function(e){window.open(this.src)}
- }
- }
- }
- //-->
- </script>
-
-
-
-
-
-
-
-
-
- <a href="$value[url]" target="_blank"><img src="{$value[attachment]}" onload="javascript:if (this.width>500 ){this.width=600;}"></a>
- <p><font size="2" color="#000000">$value[message]</font></p>
-
-
- <table width="80%" border="0">
-
- <tr>
-
- <td width="35%" ><h4><a href="$value[url]">详细内容</a></h4></td>
- <td><font size="2" color="#000000"><b>    创意指数:$value[avers]    实用指数:$value[averu]     综合指数:$value[alla]</b></font></td>
-
- </tr>
-
-
-
-
- </table>
-
-
-
- </li>
-
- <!--{/loop}-->
- </ul>
- <!--{if $_SBLOCK[newlist1_multipage]}-->
- $_SBLOCK[newlist1_multipage]
- <!--{else}-->
- <div class="pages">
- 当前只有一页
- </div>
- <!--{/if}-->
- <!--{/if}-->
- <!--{/if}-->
- </div>
-
- </div><!--col1 end-->
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- <div class="col2">
- <div id="user_login">
- <script src="{S_URL}/batch.panel.php?rand={eval echo rand(1, 999999)}" type="text/javascript" language="javascript"></script>
- </div><!--user_login end-->
-
-
-
-
-
-
- <!--{block name="announcement" parameter="order/displayorder DESC,starttime DESC/limit/0,3/cachetime/96400/subjectlen/34/subjectdot/0/cachename/announce"}-->
- <div class="super_notice">
- <h3>公告:</h3>
- <ul>
- <!--{if empty($_SBLOCK['announce'])}-->
- <li>暂时没有公告</li>
- <!--{else}-->
- <!--{loop $_SBLOCK['announce'] $value}-->
- <li><a href="$value[url]" title="$value[subjectall]">$value[subject]</a></li>
- <!--{/loop}-->
- <!--{/if}-->
- </ul>
- </div><!--公告end-->
-
-
-
- <!--{block name="poll" parameter="order/dateline DESC/limit/0,3/cachetime/80000/cachename/poll"}-->
- <div class="super_notice margin_bot0">
- <h3>调查:</h3>
- <ul>
- <!--{if empty($_SBLOCK['poll'])}-->
- <li>暂时没有调查</li>
- <!--{else}-->
- <!--{loop $_SBLOCK['poll'] $value}-->
- <li><a href="$value[url]">$value[subject]</a></li>
- <!--{/loop}-->
- <!--{/if}-->
- </ul>
- </div><!--调查end-->
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- <!--板块根据帖子数排行-->
- <!--{block name="bbsforum" parameter="type/forum/allowblog/1/order/posts DESC/limit/0,10/cachetime/14400/cachename/hotforums/tpl/data"}-->
- <div class="global_module global_tx_list5">
- <div class="global_module2_caption"><h3>版块帖子数排行</h3></div>
- <ul>
- <!--{loop $_SBLOCK['hotforums'] $value}-->
- <li><span class="box_r">$value[posts]</span><a href="http://www.ideame.cn/?action-forumdisplay-fid-$value[fid]">$value[name]</a></li>
- <!--{/loop}-->
- </ul>
- </div>
-
- <!--{block name="bbsmember" parameter="order/m.posts DESC/limit/0,10/cachetime/86400/cachename/hotmembers/tpl/data"}-->
- <div class="global_module global_tx_list5">
- <div class="global_module2_caption"><h3>用户发帖排行</h3></div>
- <ul>
- <!--{loop $_SBLOCK['hotmembers'] $value}-->
- <li><span class="box_r">$value[posts]</span><a href="$value[url]">$value[username]</a></li>
- <!--{/loop}-->
- </ul>
- </div>
- <!--{block name="bbsmember" parameter="order/m.oltime DESC/limit/0,10/cachetime/86400/cachename/toponline/tpl/data"}-->
- <div class="global_module global_tx_list5">
- <div class="global_module2_caption"><h3>用户在线排行</h3></div>
- <ul>
- <!--{loop $_SBLOCK['toponline'] $value}-->
- <li><span class="box_r">$value[oltime]小时</span><a href="$value[url]">$value[username]</a></li>
- <!--{/loop}-->
- </ul>
- </div>
- <!--最新更新帖子-->
- <!--{block name="bbsthread" parameter="order/lastpost DESC/limit/0,10/subjectlen/28/subjectdot/0/cachetime/11460/cachename/newpost/tpl/data"}-->
- <!--{if $_SBLOCK['newpost']}-->
- <div class="global_module global_tx_list5">
- <div class="global_module2_caption"><h3>最新评论</h3></div>
- <ul>
- <!--{loop $_SBLOCK['newpost'] $value}-->
- <li><span class="box_r">#date('m-d', $value[lastpost])#</span><a href="$value[url]">$value[subject]</a></li>
- <!--{/loop}-->
- </ul>
- </div>
- <!--{/if}-->
-
- <!--创意指数-->
- <!--{block name="bbsattachment" parameter="sql/SELECT%20%20%20%2A%20%0D%0AFROM%20%20cdb_posts%20where%20first%3D1%20GROUP%20BY%20subject%20%20ORDER%20BY%20avers%20DESC/limit/0,10/cachetime/900/cachename/lists/tpl/data"}--><!--lists-->
- <div class="global_module global_tx_list5">
- <div class="global_module2_caption"><h3>创意指数TOP10</h3></div>
- <ul>
-
- <!--{loop $_SBLOCK[lists] $value}-->
-
- <li><span class="box_r">$value[avers]</span><a href="$value[url]">$value[subject]</a></li>
-
-
- <!--{/loop}-->
- </ul>
-
- </div>
-
-
-
-
-
-
-
- <!--实用指数-->
- <!--{block name="bbsattachment" parameter="sql/SELECT%20%20%20%2A%20%0D%0AFROM%20%20cdb_posts%20where%20first%3D1%20GROUP%20BY%20subject%20%20ORDER%20BY%20averu%20DESC/limit/0,10/cachetime/900/cachename/listu/tpl/data"}--><!--listu-->
- <div class="global_module global_tx_list5">
- <div class="global_module2_caption"><h3>实用指数TOP10</h3></div>
- <ul>
-
- <!--{loop $_SBLOCK[listu] $value}-->
-
- <li><span class="box_r">$value[averu]</span><a href="$value[url]">$value[subject]</a></li>
-
-
- <!--{/loop}-->
- </ul>
-
- </div>
-
-
-
- <!--综合指数-->
- <!--{block name="bbsattachment" parameter="sql/SELECT%20%20%20%2A%20%0D%0AFROM%20%20cdb_posts%20where%20first%3D1%20GROUP%20BY%20subject%20%20ORDER%20BY%20alla%20DESC/limit/0,10/cachetime/900/cachename/lista/tpl/data"}--><!--lista-->
- <div class="global_module global_tx_list5">
- <div class="global_module2_caption"><h3>综合指数TOP10</h3></div>
- <ul>
-
- <!--{loop $_SBLOCK[lista] $value}-->
-
- <li><span class="box_r">$value[alla]</span><a href="$value[url]">$value[subject]</a></li>
-
-
- <!--{/loop}-->
- </ul>
-
- </div>
- <!--{block name="uchblog" parameter="dateline/2592000/order/viewnum DESC,dateline DESC/limit/0,13/cachetime/97643/subjectlen/26/subjectdot/0/cachename/bloghottop"}-->
- <!--{if !empty($_SBLOCK['bloghottop'])}-->
- <!--{eval $bloghottop = @array_slice($_SBLOCK['bloghottop'], 0, 3);}-->
- <!--{/if}-->
- <div id="blog_top">
- <h3>日志之星</h3>
- <!--{loop $bloghottop $value}-->
- <dl>
- <dt><a href="{S_URL}/space.php?uid=$value[uid]"><img src="{UC_API}/avatar.php?uid=$value[uid]&size=small" alt="" /></a><span><a href="{S_URL}/space.php?uid=$value[uid]">$value[username]</a></span></dt>
- <dd>
- <a href="$value[url]" title="$value[subjectall]">$value[subject]</a><br />
- 浏览($value[viewnum]) | 评论($value[replynum])
- </dd>
- </dl>
- <!--{/loop}-->
- </div><!--blog_top end-->
- </div><!--col2 end-->
- </div><!--column end-->
- <!--{if !empty($ads2['siderad'])}-->
- <div class="global_module margin_bot10 bg_fff">
- <div class="global_module2_caption"><h3>网络资源</h3></div>
- <div class="ad_sidebar">
- $ads2[siderad]
- </div>
- </div>
- <!--{/if}-->
- </div><!--col2 end-->
- </div><!--column end-->
- <!--{if !empty($ads2['pagefootad'])}-->
- <div class="ad_pagebody">$ads2['pagefootad']</div>
- <!--{/if}-->
- <!--{if !empty($ads2['pagemovead']) || !empty($ads2['pageoutad'])}-->
- <!--{if !empty($ads2['pagemovead'])}-->
- <div id="coupleBannerAdv" style="z-index: 10; position: absolute; width:100px;left:10px;top:10px;display:none">
- <div style="position: absolute; left: 6px; top: 6px;">
- $ads2[pagemovead]
- <br />
- <img src="{S_URL}/images/base/advclose.gif" onMouseOver="this.style.cursor='hand'" onClick="closeBanner('coupleBannerAdv');">
- </div>
- <div style="position: absolute; right: 6px; top: 6px;">
- $ads2[pagemovead]
- <br />
- <img src="{S_URL}/images/base/advclose.gif" onMouseOver="this.style.cursor='hand'" onClick="closeBanner('coupleBannerAdv');">
- </div>
- </div>
- <!--{/if}-->
- <!--{if !empty($ads2['pageoutad'])}-->
- <div id="floatAdv" style="z-index: 10; position: absolute; width:100px;left:10px;top:10px;display:none">
- <div id="floatFloor" style="position: absolute; right: 6px; bottom:-700px">
- $ads2[pageoutad]
- </div>
- </div>
- <!--{/if}-->
- <script type="text/javascript" src="{S_URL}/include/js/floatadv.js"></script>
- <script type="text/javascript">
- <!--{if !empty($ads2['pageoutad'])}-->
- var lengthobj = getWindowSize();
- lsfloatdiv('floatAdv', 0, 0, 'floatFloor' , -lengthobj.winHeight).floatIt();
- <!--{/if}-->
- <!--{if !empty($ads2['pagemovead'])}-->
- lsfloatdiv('coupleBannerAdv', 0, 0, '', 0).floatIt();
- <!--{/if}-->
- </script>
- <!--{/if}-->
- <!--{template footer}-->
复制代码 结果可以把图片和文字调出来,效果如图
但是列表却显示错误,它把所有的帖子全显示在一页了,不是我设置的10贴每页,错误如图
请dz官方人员或者高手提示一下好吗?谢谢了!如果不可以,请问为什么,如果可以,哪怕是只有一点点希望,请给在下一点提示好吗? |