CooL.泪猪 发表于 2012-7-29 23:35:02

DZX2.0版图片版瀑布流分享

近日看到网上流行的瀑布流,也参照改了下,但是网上的forumdisplay_list.htm都是全部替换form表单里的所有项,直接影响到的是非图片版帖子列表界面,其实没必要把form表单里的所有项都替换,仅替换“else if 图片部分+分页”部分即可。
为了完整方法跟其他帖写的都一样,为方便新手,操作如下:

1、将qing模板目录下\image\redef.js移动至正在使用模板的图片存放目录,同时将qing模板中的bg_waterfall.png、bg_pgbtn.png移动至当前模板图片目录。
2、模板目录下增加common\extend_common.css,其内容如下:
/* 大分页按钮 by Pony 1203121325 */
.pgbtn { margin: 5px 0 10px; }
.pgbtn a { display: block; height: 40px; line-height: 40px; letter-spacing: 5px; text-align: center; border: 1px solid #DCDCDC; background: #F5F5F5 url({STYLEIMGDIR}/bg_pgbtn.png) repeat-x 0 0; font-size: 14px; outline: none; border-radius: 5px; box-shadow: 0 1px 0 #F5F5F5; }
.pgbtn a:hover { border-color: #BABABA; text-decoration: none; }
.pgbtn a:active { background: #EEE; border-color: #D0D0D0; box-shadow: none; }

/* 瀑布流布局 by Pony 1204121803 */
.waterfall { position: relative; margin-top: 15px; }
.waterfall li { margin: 0 10px 10px 0; padding: 0 0 3px; text-align: left; border-width: 1px 0 0; border-top: 1px solid #EAEAEA; background: url({STYLEIMGDIR}/bg_waterfall.png) no-repeat 100% 100%; }
.waterfall .c, .waterfall h3 { padding: 10px; border: solid #EAEAEA; border-width: 0 1px; background-color: #F8F8F8; }
.waterfall .c { overflow: hidden; padding-bottom: 0; max-height: 800px; }
.waterfall .c .nopic { display: block; background:{WRAPBG} url({IMGDIR}/nophototiny.png) no-repeat 50% 50%; cursor: pointer; }
.waterfall .auth { padding: 0 10px 10px; border-width: 0 1px 1px; border-style: solid; border-color: transparent #EAEAEA #B9B9B9; background: #F8F8F8; }
.waterfall .auth img { display: inline-block; margin: 0 1px; }
3、拷贝qing\forum\forumdisplay_list.htm文件里的“else if 图片部分+分页”替换default里的forumdisplay_list.htm的相应图片部分(即从<!-- end of table "forum_G" branch 2/3 --> 开始到</form>结束)。
<!--{else}-->
</table><!-- end of table "forum_G" branch 2/3 -->
<ul id="waterfall" class="ml waterfall cl">
<!--{loop $_G['forum_threadlist'] $key $thread}-->
<!--{if !$thread['forumstick'] && ($thread['isgroup'] == 1 || $thread['fid'] != $_G['fid'])}-->
<!--{if $thread['related_group'] == 0 && $thread['closed'] > 1}-->
<!--{eval $thread=$thread;}-->
<!--{/if}-->
<!--{/if}-->
<!--{eval $waterfallwidth = $_G + 24; }-->
<li style="width:{$waterfallwidth}px;">
<!--{if !$_GET['archiveid'] && $_G['forum']['ismoderator']}-->
<div style="position:absolute;margin:1px;padding:2px;background:#FFF">
<!--{if $thread['fid'] == $_G}-->
<!--{if $thread['displayorder'] <= 3 || $_G['adminid'] == 1}-->
<input onclick="tmodclick(this)" type="checkbox" name="moderate[]" value="$thread" />
<!--{else}-->
<input type="checkbox" disabled="disabled" />
<!--{/if}-->
<!--{else}-->
<input type="checkbox" disabled="disabled" />
<!--{/if}-->
</div>
<!--{/if}-->
<div class="c cl">
<a href="forum.php?mod=viewthread&tid=$thread&{if $_GET['archiveid']}archiveid={$_GET['archiveid']}&{/if}extra=$extra" {if $thread['isgroup'] == 1 || $thread['forumstick'] || CURMODULE == 'guide'} target="_blank"{else} onclick="atarget(this)"{/if} title="$thread" class="z">
<!--{if $thread['cover']}-->
<img src="$thread" alt="$thread" width="{$_G}" />
<!--{else}-->
<span class="nopic" style="width:{$_G}px; height:{$_G}px;"></span>
<!--{/if}-->
</a>
</div>
<h3 class="xw0">
<!--{hook/forumdisplay_thread $key}-->
<a href="forum.php?mod=viewthread&tid=$thread&{if $_GET['archiveid']}archiveid={$_GET['archiveid']}&{/if}extra=$extra"$thread{if $thread['isgroup'] == 1 || $thread['forumstick']} target="_blank"{else} onclick="atarget(this)"{/if} title="$thread">$thread</a>
</h3>
<div class="auth cl">
<cite class="xg1 y">
{echo '喜欢'}: <!--{if $thread}-->$thread<!--{else}-->0<!--{/if}-->
{lang reply}: <a href="forum.php?mod=viewthread&tid=$thread&extra=$extra" title="$thread {lang reply}">$thread</a>
</cite>
<!--{hook/forumdisplay_author $key}-->
<!--{if $thread['authorid'] && $thread['author']}-->
<a href="home.php?mod=space&uid=$thread">$thread</a><!--{if !empty($verify[$thread['authorid']])}--> $verify[$thread]<!--{/if}-->
<!--{else}-->
$_G
<!--{/if}-->
</div>
</li>
<!--{/loop}-->
</ul>
<div id="tmppic" style="display: none;"></div>
<script type="text/javascript" src="$_G['style']['styleimgdir']/redef.js?{VERHASH}"></script>
<script type="text/javascript" reload="1">
var wf = {};

_attachEvent(window, "load", function () {
if($("waterfall")) {
wf = waterfall();
}

<!--{if $page < $_G['page_next'] && !$subforumonly}-->
var page = $page + 1,
maxpage = $page + 10,
stopload = 0,
scrolltimer = null,
tmpelems = [],
tmpimgs = [],
markloaded = [],
imgsloaded = 0,
loadready = 0,
showready = 1,
nxtpgurl = 'forum.php?mod=forumdisplay&fid={$_G}&filter={$filter}&orderby={$_GET}{$forumdisplayadd}&page=',
wfloading = "<img src=\"{IMGDIR}/loading.gif\" alt=\"\" width=\"16\" height=\"16\" class=\"vm\" /> 加载中...",
pgbtn = $("pgbtn").getElementsByTagName("a");

function loadmore() {
var url = nxtpgurl + page + '&t=' + parseInt((+new Date()/1000)/(Math.random()*1000));
var x = new Ajax("HTML");
x.get(url, function (s) {
s = s.replace(/\n|\r/g, "");
if(s.indexOf("id=\"pgbtn\"") == -1) {
$("pgbtn").style.display = "none";
stopload++;
window.onscroll = null;
}

s = s.substring(s.indexOf("<ul id=\"waterfall\""), s.indexOf("<div id=\"tmppic\""));
s = s.replace("id=\"waterfall\"", "");
$("tmppic").innerHTML = s;
loadready = 1;
});
}

window.onscroll = function () {
if(scrolltimer == null) {
scrolltimer = setTimeout(function () {
try {
if(page < maxpage && stopload < 2 && showready && ((document.documentElement.scrollTop || document.body.scrollTop) + document.documentElement.clientHeight + 500) >= document.documentElement.scrollHeight) {
pgbtn.innerHTML = wfloading;
loadready = 0;
showready = 0;
loadmore();
tmpelems = $("tmppic").getElementsByTagName("li");
var waitingtimer = setInterval(function () {
stopload >= 2 && clearInterval(waitingtimer);
if(loadready && stopload < 2) {
if(!tmpelems.length) {
page++;
pgbtn.href = nxtpgurl + page;
pgbtn.innerHTML = "{echo '下一页 &raquo;'}";
showready = 1;
clearInterval(waitingtimer);
}
for(var i = 0, j = tmpelems.length; i < j; i++) {
if(tmpelems) {
tmpimgs = tmpelems.getElementsByTagName("img");
imgsloaded = 0;
for(var m = 0, n = tmpimgs.length; m < n; m++) {
tmpimgs.onerror = function () {
this.style.display = "none";
};
markloaded = tmpimgs.complete ? 1 : 0;
imgsloaded += markloaded;
}
if(imgsloaded == tmpimgs.length) {
$("waterfall").appendChild(tmpelems);
wf = waterfall({
"index": wf.index,
"totalwidth": wf.totalwidth,
"totalheight": wf.totalheight,
"columnsheight": wf.columnsheight
});
}
}
}
}
}, 40);
}
} catch(e) {}
scrolltimer = null;
}, 320);
}
};
<!--{/if}-->

});

</script>
<!--{/if}-->
<!--{else}-->
<tbody class="bw0_all"><tr><th colspan="{if !$_GET['archiveid'] && $_G['forum']['ismoderator']}4{else}3{/if}"><p class="emp">{lang forum_nothreads}</p></th></tr></tbody>
</table><!-- end of table "forum_G" branch 3/3 -->

<!--{if $_G['setting']['threadmaxpages'] > 1 && $page && !$subforumonly && $page < $_G['setting']['threadmaxpages'] && $page < $_G['page_next']}-->
<!--{eval $nxtpage = $page + 1;}-->
<div id="pgbtn" class="pgbtn"><a href="forum.php?mod=forumdisplay&fid={$_G}&filter={$filter}&orderby={$_GET}{$forumdisplayadd}&{$multipage_archive}&page=$nxtpage" hidefocus="true">{echo '下一页 &raquo;'}</a></div>
<!--{/if}-->

<!--{/if}-->
<!--{if $_G['forum']['ismoderator'] && $_G['forum_threadcount']}-->
<!--{template forum/topicadmin_modlayer}-->
<!--{/if}-->
</form>
4、后天帖子列表界面,图片宽度设为200,高度9999,相应版块开启图片版即可

5、如果你需要向下加载的话,需要把分页代码一起复制进forumdisplay_list.htm去

演示:http://www.coqq.net/forum-75-1.html
页: [1]
查看完整版本: DZX2.0版图片版瀑布流分享

欢迎您的光临,如果您觉得本站做得不错的话,请把本站介绍给您的好友,谢谢大家的支持!