discuz帖子页显示相关的主题列表(DZ6.0,6.1通用版)

每一篇帖子都是演示效果.有TAG的显示TAG相关主题列表,没有的,显示作者相关主题列表.
功能:
能够随机显示主题TAG相应主题列表.
无TAG时,将显示主题发表作者相应主题列表.
无限乱数,将不会有重复主题出现.
有效地解决吸引游客等问题.
更大化优化收录及站点链接.

找到viewthread.php.
查找:
程序代码 程序代码
viewthread_updateviews();


在它的上面添加:
程序代码 程序代码

$tagsa = explode(',',$metakeywords);

$count=count($tagsa)-2;

$sunm=rand(0,$count);

if(empty($metakeywords)){

        $query = $db->query("Select `tid`,`author` FROM `cdb_posts` Where `tid` =$tid AND `first`>0 LIMIT 0,1");

     while ($authora=$db->fetch_array($query)){

             $author['author']=$authora['author'];

     }

     unset($query);

}

!empty($metakeywords)?$sql="Select `tid`,`subject`,`author`,`dateline` FROM `cdb_posts` Where `first`>0 AND `subject` LIKE '%$tagsa[$sunm]%' COLLATE gbk_chinese_ci LIMIT 0,5":$sql="Select *

FROM `cdb_posts` Where `author`='{$author['author']}' AND `tid`!=$tid AND  `first`>0 orDER BY `pid` DESC LIMIT 0 , 5 ";

$tagarray=array();

$tagsell = array();

$query = $db->query("$sql");

while ($tagsell=$db->fetch_array($query)) {

    $tagsell['tid'] = $tagsell['tid'];

        $tagsell['subject'] = cutstr($tagsell['subject'],45);

        $tagsell['author'] = cutstr($tagsell['author'],9);

                $tagsell['dateline']= gmdate("$dateformat $timeformat", $tagsell['dateline'] + $timeoffset * 3600);

                $tagarray[] = $tagsell;

}


注意:cdb_posts 里cdb为数据库前缀, 更改为自己网站的前缀即可.


打开viewthread.htm文件,
查找:
程序代码 程序代码

<!--{if $post['signature'] && !$post['anonymous'] && $showsignatures}-->

                                                        <div class="signatures" style="maxHeightIE: {MAXSIGROWS}px;">

                                                                $post[signature]

                                                        </div>

                                                <!--{/if}-->


1.如果启用了贴子静态化在它的上面添加:
程序代码 程序代码

<!--{if !empty($tagarray)&&$post['number']==1}-->

                <h3 style="background:none; border:1px solid #99CC33; color:#333333"><span><!--{if empty($metakeywords)}-->该用户相关主题列表<!--{else}-->{lang thread_keywords}<!--{/if}-->

                                                                <!--{if $thread['tags']}-->$thread[tags]<!--{/if}--></span></h3>

                         <!--{loop $tagarray $tagsell}-->

      <div style="border:1px solid #99CC33;margin-top:2px; line-height:25px; width:100%;"><span style="float:left; line-height:25px; width:150px; text-align:left; border-right:1px solid #99CC33; margin-left:5px;"> <font color="#666666">作者</font>: <a href="./space.php?username=$tagsell[author]" target="_blank">$tagsell[author]</a></span><span style="float:left; line-height:25px; width:400px; text-align:left; border-right:1px solid #99CC33; margin-left:5px;"> <font color="#666666">主题</font>: <a href="./thread-$tagsell[tid]-1-1.html" target="_blank">$tagsell[subject]</a></span><span style="float:left; line-height:25px; width:150px; text-align:left; margin-right:1px solid #99CC33;  margin-left:5px;"> <font color="#666666">时间</font>: $tagsell[dateline]</span></div>

      <!--{/loop}-->

       <!--{/if}-->


2.如果没有启用了贴子静态化在它的上面添加:
程序代码 程序代码

<!--{if !empty($tagarray)&&$post['number']==1}-->

                <h3 style="background:none; border:1px solid #99CC33; color:#333333"><span><!--{if empty($metakeywords)}-->该用户相关主题列表<!--{else}-->{lang thread_keywords}<!--{/if}-->

                                                                <!--{if $thread['tags']}-->$thread[tags]<!--{/if}--></span></h3>

                         <!--{loop $tagarray $tagsell}-->

      <div style="border:1px solid #99CC33;margin-top:2px; line-height:25px; width:100%;"><span style="float:left; line-height:25px; width:150px; text-align:left; border-right:1px solid #99CC33; margin-left:5px;"> <font color="#666666">作者</font>: <a href="./space.php?username=$tagsell[author]" target="_blank">$tagsell[author]</a></span><span style="float:left; line-height:25px; width:400px; text-align:left; border-right:1px solid #99CC33; margin-left:5px;"> <font color="#666666">主题</font>: <a href="./viewthread.php?tid=$tagsell[tid]" target="_blank">$tagsell[subject]</a></span><span style="float:left; line-height:25px; width:150px; text-align:left; margin-right:1px solid #99CC33;  margin-left:5px;"> <font color="#666666">时间</font>: $tagsell[dateline]</span></div>

      <!--{/loop}-->

       <!--{/if}-->


更新缓存 OK!


评论: 0 | 引用: 0 | 查看次数: 8460
发表评论
昵 称:
密 码: 游客发言不需要密码.
内 容:
验证码: 验证码
选 项:
虽然发表评论不用注册,但是为了保护您的发言权,建议您注册帐号.
字数限制 2 字 | UBB代码 开启 | [img]标签 关闭