anchen 发表于 2009-7-1 17:23:49

鼠标掠过主题列表图片附件即时预览 FOR DZ7.0 20081224 支持IE6,IE7,FF


1.后台升级数据库ALTER TABLE cdb_forums ADD valueattach tinyint(1) NOT NULL default '0';
ALTER TABLE cdb_forumfields ADD valueattach tinyint(1) NOT NULL default '0';2.修改 /forumdisplay.php
查找while(($querysticky && $thread = $sdb->fetch_array($querysticky)) || ($query && $thread = $sdb->fetch_array($query)) || ($queryfloat && $thread = $sdb->fetch_array($queryfloat))) {上面加$querya = $db->query("SELECT tid, filetype, attachment FROM {$tablepre}attachments ORDER BY aid");
while($attach = $db->fetch_array($querya)){
      $attachtid[] = $attach['tid'];
      $attachment[] = $attach['attachment'];
      $attachtype[] = $attach['filetype'];
}查找$threadlist[] = $thread;上面加if($thread['attachment']){

               foreach($attachtid as $key => $value){

                         if($thread['tid'] == $value){

                                 if($isimage = preg_match("/^image\/.+/", $attachtype[$key])){

                                       $thread['attach'] = $attachment[$key];

                                 }

                         }

               }      

         }3.修改 admin/forums.inc.php
查找showsetting('forums_edit_basic_display', 'statusnew', $forum['status'], 'radio');下面加showsetting('forums_edit_valueattach', 'valueattachnew', $forum['valueattach'], 'radio');查找password='$passwordnew',后面加(注意前后有空格,不然会出错):valueattach='$valueattachnew', 4.修改 template/default/admincp.lang.php
查找'forums_edit_basic_display_comment' => '选择“否”将暂时将版块隐藏不显示,但版块内容仍将保留,且用户仍可通过直接提供带有 fid 的 URL 访问到此版块',下面加'forums_edit_valueattach' => '选择是否使用附件图片主题预览功能:',
'forums_edit_valueattach_comment' => '在版块每个主题上显示附件图片预览。',5.修改 templates\default\header.htm (如果你使用的不是默认DZ风格请根据个人情况修改)
查找<script type="text/javascript" src="include/js/common.js?{VERHASH}"></script>后面加<script type="text/javascript" src="include/js/showimage.js?{VERHASH}"></script>6.修改模板 templates\default\forumdisplay.htm(如果你使用的不是默认DZ风格请根据个人情况修改) 查找<li class="wide"><a href="viewthread.php?tid=$tid" $thread['subjectstyles'] target="_blank">$thread</a><cite>-<a href="space.php?uid=$thread" target="_blank">$thread</a></cite></li>替换成<li>
<!=========主题列表图片附件即时预览 DZ7.0================>
<!--{if $thread['displayorder'] == 1 || $thread['displayorder'] == 2 || $thread['displayorder'] == 3 }-->

   <!--{if $thread['attach']}-->

      <div id="showimage" style="position:fixed; _position:absolute; margin-top: -400px; _margin-top: -600px; margin-left: 250px; _margin-left: 100px; visibility:hidden; border:1px"></div>

                <a onMouseOver="return enlarge('attachments/$thread',event)" onMouseOut="closepreview()" yle="cursor:hand"

href="viewthread.php?tid=$thread&extra=$extra$thread['subjectstyles'] target="_blank""$thread>$thread</a>

      <!--{else}-->

   <cite><a href="viewthread.php?tid=$thread">$thread</a>

<!--{/if}-->

<!--{else}-->

<!--{if $forum['valueattach']}-->

<!--{if $thread['attach']}-->

      <div id="showimage" style="position:fixed; _position:absolute; margin-top: -400px; _margin-top: -600px; margin-left: 250px; _margin-left: 100px; visibility:hidden; border:1px"></div>

                <a onMouseOver="return enlarge('attachments/$thread',event)" onMouseOut="closepreview()" style="cursor:hand" href="viewthread.php?tid=$thread&extra=$extra"$thread>"$thread>$thread</a>

      <!--{else}-->

   <cite><a href="viewthread.php?tid=$thread">$thread</a>

<!--{/if}-->

<!--{else}-->

<a href="viewthread.php?tid=$thread">$thread</a>

<!--{/if}-->

<!--{/if}-->
<!==========主题列表图片附件即时预览 DZ7.0===============>
</li>查找<span id="thread_$thread"><a href="viewthread.php?tid=$thread&amp;extra=$extra"$thread>$thread</a></span>替换成<span id="thread_$thread">
<!=========主题列表图片附件即时预览 DZ7.0================>
<!--{if $thread['displayorder'] == 1 || $thread['displayorder'] == 2 || $thread['displayorder'] == 3 }-->

<!--{if $thread['attach']}-->

      <div id="showimage" style="position:fixed; _position:absolute; margin-top: -400px; _margin-top: -600px; margin-left: 250px; _margin-left: 100px; visibility:hidden; border:1px"></div>

      <a onMouseOver="return enlarge('attachments/$thread',event)" onMouseOut="closepreview()" style="cursor:hand" href="viewthread.php?tid=$thread&extra=$extra"$thread>$thread</a>

      <!--{else}-->

   <a href="viewthread.php?tid=$thread&extra=$extra"$thread>$thread</a>

<!--{/if}-->

<!--{else}-->

<!--{if $forum['valueattach']}-->

<!--{if $thread['attach']}-->

      <div id="showimage" style="position:fixed; _position:absolute; margin-top: -400px; _margin-top: -600px; margin-left: 250px; _margin-left: 100px; visibility:hidden; border:1px"></div>

       <a onMouseOver="return enlarge('attachments/$thread',event)" onMouseOut="closepreview()" style="cursor:hand" href="viewthread.php?tid=$thread&extra=$extra"$thread>$thread</a>

      <!--{else}-->

   <a href="viewthread.php?tid=$thread&extra=$extra"$thread>$thread</a>

<!--{/if}-->

<!--{else}-->

<a href="viewthread.php?tid=$thread&extra=$extra"$thread>$thread</a>

<!--{/if}-->

<!--{/if}-->
<!==========主题列表图片附件即时预览 DZ7.0===============>

   </span>下载附件showimage.rar解压复制到论坛根目录下的 \include\js 目录下
在后台开启功能,更新缓存,刷新页面。安装成功!
修改缩略图大小在showimage.js 里
查找'<div style="background-color:#E1E3E5;padding:5px;"><img src="'+which+'" style="width:expression(this.width > 600 && (this.height-400) <= (this.width-600) ? 600:true); height:expression(this.height >400 &&(this.height-400)>(this.width-600)? 400:true); max-width:600px; max-height:400px;"></div>'把所有的 600 替换成你图片的像素宽度
把所有的 400 替换成你图片的像素高度


错误修正(看清楚了自己的问题在修改)
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------

1.图片定位变形不居中?
如果安装完后出现图片居底,修改一下 templates\default\forumdisplay.htm<div id="showimage" style="position:fixed; _position:absolute; margin-top: -400px; _margin-top: -600px; margin-left: 250px; _margin-left: 100px; visibility:hidden; border:1px"></div>替换成<div id="showimage" style="position:fixed; *position:absolute; *+position:absolute; margin-top: -750px; *margin-top: -900px; margin-left: 380px; *margin-left:150px; *+margin-left:80px; visibility:hidden; border:1px"></div>一共有4处,定位会居中一点。没有问题的不要修改。

2.不能显示批量上传的图片附件?
对批量上传图片不显示的问题,只有等官方发文件类型分类才能实现了
用FLASH的批量上传会把上传的所有文件类型定为application/octet-stream ,是为了适应任何类型文件.
而image/pjpeg才是能被显示出来的图片文件类型,这个只能到数据库 cdb_attachments 改 filetype 字段
解决方法:再次修改 /forumdisplay.php
先删除if($isimage = preg_match("/^image\/.+/", $attachtype[$key]))在查找$querya = $db->query("SELECT tid, filetype, attachment FROM {$tablepre}attachments ORDER BY aid修改为$querya = $db->query("SELECT tid, filetype, attachment FROM {$tablepre}attachments WHERE `isimage` = 1 ORDER BY aid这种做法非常耗资源...OTL

3.修改显示图片顺序?
默认的是显示最后一个图片的缩略图,要想显示随机图片的缩略图,再次修改 /forumdisplay.php
查找ORDER BY aid");修改为ORDER BY aid AND isimage=1");4.想不显示已售价的图片?
再次修改 /forumdisplay.php
查找ORDER BY aid");修改为ORDER BY aid AND price=0");5.DZ7 20081224以后的版本会出现图片定位问题?
在修改 templates\default\forumdisplay.htm<div id="showimage" style="position:fixed; _position:absolute; margin-top: -400px; _margin-top: -600px; margin-left: 250px; _margin-left: 100px; visibility:hidden; border:1px"></div>根据自己的情况修改,注意不同浏览器的修改位置

6.卸载?
执行SQLALTER TABLE cdb_forums DROP valueattach;
ALTER TABLE cdb_forumfields DROP valueattach;在把修改过的文件反相修改回去

231aaa 发表于 2009-7-6 18:58:13

哈哈这可以
页: [1]
查看完整版本: 鼠标掠过主题列表图片附件即时预览 FOR DZ7.0 20081224 支持IE6,IE7,FF