前些天..和大家一起分析了forumdisplay.htm模板代码,详细可以看这个帖子:http://www.discuz.net/thread-459921-1-1.html,
其中涉及的变量,大家可以参考M55等人收录总结出来的变量列表:http://www.discuz.net/thread-329110-1-1.html
记得M55说过..授人以鱼不如授人以渔
,
   大家不要一味上来就要求要这个,要那个..浪费时间不说.除去好心人提供的一些东西外,也得不到什么,这也是导致DISCUZ现在论坛的风气不好的一个 主要原因..我觉得,以前那个相互学习的氛围没有了..所以说..大家还是最好还是扎扎实实的学些东西.从很基本的开始做起,好比喻说..细心看看我写的 这几篇东东,虽然是很表面的东西,可是,又有多少人认真去看了呢?
  或者,看慬了,又有多少人耐着性子,拿出来和大家一起分享了呢?
  还是那一句,我写的这些东西,主要是面对新手..好像我这样,想学东西,但又什么都不慬的,就给点精神,细细的看完..但如果是高手,笑笑过就算了..
  宗旨:
共同学习..一起提高!


   很多人说要看viewthead.htm的.好..现在VIEWTHEAD的..也写上来了..

   还是和上次一样(分析用的是default下的viewthead.htm模板...顺序是从上到下...一段一段的解释..其中与forumdisplay.htm中调用相同的模块的,就只是标出,不详细介绍了..
   好下面正式开始..
  
{template header}
...火星人都知道了吧...
  
  <div class="subtable nav" style="width:{TABLEWIDTH}">
  1. <!--{if $searchboxstatus}-->
  2.         <div class="right">
  3.         <form method="post" action="search.php?srchtype=qihoo" onSubmit="this.target='_blank';">
  4.         <input type="hidden" name="searchsubmit" value="yes">
  5.         <input type="text" name="srchtxt" value="$qihoo_searchboxtxt" size="27" class="input" style="{BGCODE}" onmouseover="this.focus();this.value='';this.onmouseover=null;" onfocus="this.select()">
  6.         <!--{if $qihoo_allsearch != '2'}--><input name="searchsubmit" class="button" type="submit" value="{lang search}"><!--{/if}-->
  7.         <!--{if $qihoo_allsearch}-->
  8.                 <input name="allsearchsubmit" class="button" type="submit" value="{lang qihoo_search}">
  9.         <!--{/if}-->
  10.         </form>
  11.         </div>
  12. <!--{/if}-->
复制代码
这个是帖子右上角的垃圾QIHOO搜索..不多说...
复制代码
论坛版块下拉菜单(JS调用)
  1. $navigation
复制代码
这个函数是控制输出:帖子所属的版块,和帖子标题
</div><br></div>
  1. <!--{if !empty($advlist['text'])}-->
  2.         <div class="maintable">
  3.         <div class="spaceborder" style="width: {TABLEWIDTH}">
  4.         <table cellspacing="1" border="0" cellpadding="{TABLESPACE}" width="100%" style="background: {BGBORDER}">$advlist[text]</table>
  5.         </div><br></div>
  6. <!--{/if}-->
复制代码
这个是帖子上面的文字广告栏..
  1. <!--{if $newpmexists}-->
  2.         <div class="maintable">
  3.         {template pmprompt}
  4.         </div>
  5. <!--{/if}-->
复制代码
...当你有消息的时候,调用出短信提示的模板pmprompt.htm
<div class="maintable">
<table width="{TABLEWIDTH}" cellspacing="0" cellpadding="0" align="center" style="clear: both;">
<tr><td valign="bottom">
<div style="margin-bottom: {TABLESPACE}px">

复制代码
当帖子高亮被取消的时候的取消高亮的提示..

  1. <a href="redirect.php?fid=$fid&tid=$tid&goto=nextoldset" style="font-weight: normal"> ‹‹ {lang last_thread}</a> | <a href="redirect.php?fid=$fid&tid=$tid&goto=nextnewset" style="font-weight: normal">{lang next_thread} ››</a><br>
  2. </div>
复制代码
帖子左上角的:上一主题,下一主题..
  1. $multipage</td><td width="40%" align="right" valign="bottom">
  2. <!--{if $allowpostreply || !$discuz_uid}--><div class="right">&nbsp;<a href="post.php?action=reply&fid=$fid&tid=$tid&extra=$extra"><img src="{IMGDIR}/reply.gif" border="0" alt="" /></a></div><!--{/if}-->
  3. <!--{if $allowpost || !$discuz_uid}-->
  4.         <div , true)</script></div>
  5.         <!--{if ($allowposttrade && $ec_id) || $allowpostpoll || $allowpostreward || $allowpostactivity || !$discuz_uid}-->
  6.                 <div class="popupmenu_popup newspecialmenu" >
  7.                 <table cellpadding="4" cellspacing="0" border="0" width="100%">
  8.                 <!--{if $allowpostpoll || !$discuz_uid}--><tr><td class="popupmenu_option"><div class="newspecial"><a href="post.php?action=newthread&fid=$fid&extra=$extra&poll=yes">{lang thread_poll}</a></div></td></tr><!--{/if}-->
  9.                 <!--{if ($allowposttrade && $ec_id) || !$discuz_uid}--><tr><td class="popupmenu_option"><div class="newspecial"><a href="post.php?action=newthread&fid=$fid&extra=$extra&trade=yes">{lang thread_trade}</a></div></td></tr><!--{/if}-->
  10.                 <!--{if $allowpostreward || !$discuz_uid}--><tr><td class="popupmenu_option"><div class="newspecial"><a href="post.php?action=newthread&fid=$fid&extra=$extra&reward=yes">{lang thread_reward}</a></div></td></tr><!--{/if}-->
  11.                 <!--{if $allowpostactivity || !$discuz_uid}--><tr><td class="popupmenu_option"><div class="newspecial"><a href="post.php?action=newthread&fid=$fid&extra=$extra&activity=yes">{lang thread_activity}</a></div></td></tr><!--{/if}-->
  12.                 </table></div>
  13.         <!--{/if}-->
  14. <!--{/if}-->
  15. </td></tr></table></div>
复制代码
这段和forumdisplay.htm中的一样,是分页功能和发贴菜单..说到这里,大家应该也留意到了.DISCUZ很多模块是可以随意调用的..呵呵..

  1. <!--{if $thread['special'] == 1 && $polloptions}-->
  2.         <div class="maintable">
  3.         {template viewthread_poll}
  4.         </div>
复制代码
在上个帖子中,已经详细提到过$thread['special']的这个变量了,帖子的类型..为1时为投票,这样就调用出帖子投票模板viewthread_poll
  1. <!--{elseif $thread['special'] == 2}-->
  2.         <div class="maintable">
  3.         {template viewthread_trade}
  4.         </div>
复制代码
如果2时为交易,调用交易帖子的模板..
  1. <!--{elseif $thread['special'] == 4}-->
  2.         <div class="maintable">
  3.         {template viewthread_activity}
  4.         </div>
复制代码
..如果3时,调用活动帖子的模板..  ..看到这里,大家想到什么呢?我们可以改造VIEWTHRAEAD中相应帖子的表现形式了,好比喻说.我可以将这些调用插到帖子内容中去,呵呵...在相应的地方加上上面的判断语句就可以了.
<!--{/if}-->
  1. <script type="text/javascript">
  2. function fastreply(subject) {
  3.         if($('postform')) {
  4.                 $('postform').subject.value = subject;
  5.                 $('postform').message.focus();
  6.         }
  7. }
  8. </script>
复制代码
..这个我也不是很清楚..应该是下面那个快速发贴框需要用到的JS变量声明吧...希望清楚的人帮我补上这个..


好了..下面开始的就是帖子主体的内容了..包括左边的头像信息啊..右边的帖子信息啊..之类的..休息一下,大家一努力一起看下去..

下面这段是帖子标题的那一个TABLE的分析..
<div class="maintable">
<div class="spaceborder" style="width: {TABLEWIDTH}; border-bottom: none">
<table cellspacing="{INNERBORDERWIDTH}" cellpadding="{TABLESPACE}" width="100%" align="center">
<tr class="header"><td colspan="2" style="color: {HEADERTEXT}">
  1. <div class="right" style="font-weight: normal">
  2.         <a href="viewthread.php?action=printable&tid=$tid" target="_blank">{lang thread_printable}</a> |
  3.         <a href="misc.php?action=emailfriend&tid=$tid">{lang thread_email_friend}</a> |
  4.         <a href="my.php?item=subscriptions&subadd=$tid">{lang thread_subscribe}</a> |
  5.         <a href="my.php?item=favorites&favadd=$tid&type=thread">{lang thread_favorite}</a>
  6.         <!--{if $thread['authorid'] && ($thread['authorid'] == $discuz_uid || $forum['ismoderator'])}-->
  7.                 <!--{if $thread['blog']}-->
  8.                          | <a href="misc.php?action=blog&tid=$tid">{lang blog_remove}</a>
  9.                 <!--{elseif $allowuseblog && $forum['allowshare'] && $thread['authorid'] == $discuz_uid}-->
  10.                          | <a href="misc.php?action=blog&tid=$tid">{lang blog_add}</a>
  11.                 <!--{/if}-->
  12.         <!--{/if}-->
  13.         <!--{if $supe_status && $supe_siteurl}-->
  14.                 <!--{if $thread['authorid'] == $discuz_uid}-->
  15.                         <!--{if  !$thread['itemid']}-->
  16.                                 | <a href="$supe_siteurl/spacecp.php?action=spaceblogs&op=add&tid=$tid" target="_blank">{lang supe_join_xspace}</a>
  17.                         <!--{else}-->
  18.                                 | <a href="$supe_siteurl/index.php?action/viewspace/itemid/$thread[itemid]/fromdiscuz/$supe_fromdiscuz" target="_blank">{lang supe_view_in_xspace}</a>
  19.                         <!--{/if}-->
  20.                 <!--{elseif !$xspacestatus}-->
  21.                         | <a href="$supe_siteurl/index.php?action/register" target="_blank">{lang supe_register_xspace}</a>
  22.                 <!--{/if}-->
  23.                 | <a href="$supe_siteurl/spacecp.php?action=spacenews&op=add&tid=$tid" target="_blank">{lang supe_resource_add}</a>
  24.         <!--{/if}-->
  25. </div>
复制代码
我们可以看到这个div class="right" 可以根据这个,看出这个DIV大概在什么位置..具体可以参考:CSS.HTM中相应的参数.
这个DIV里面的就是帖子右上角的打印 | 推荐 | 订阅 | 收藏 | 加入文集 | 加入个人空间 | 加入资讯 的几个选项了..具体的判断语句,很简单..用IF来看相应的数组中的条件是否成立..学到现在,我们可以反过来,根据一些已经的功能,去推断一些参数的 意义了..
  1. {lang subject}:
  2. <!--{if $thread['special'] == 3}-->
  3.         <!--{if $thread['price'] > 0}-->
  4.                 [{lang reward_unsolved}]
  5.         <!--{elseif $thread['price'] < 0}-->
  6.                 [{lang reward_solved}]
  7.         <!--{/if}-->
  8. <!--{/if}-->
  9. $thread[subject]
  10. </td></tr>
复制代码
帖子左上角的帖子标题..标题前加了一个IF,看如果这个帖子是悬赏贴的话,根据$thread['price']来判断来看是否已经解决..根据那个lang,我们可以推测出,$thread['price']的意思了..查了上面的那个表,果然是.呵呵..继续.
  1. <!--{if $lastmod['modaction'] || $thread['blog'] || $thread['readperm'] || $thread['price'] != 0 || $thread[itemid]}-->
复制代码

FujiwaraSai  说多分析一下IF...好大家看看这里了..这里,有一些很简单的语法,和C应该差不多吧.."||"是或,IF.. 其中的变量,有一个为真时,执行IF下面的语句..
先看看相应的变量:,$thread['blog'],$lastmod['modaction'],$thread['readperm'] ,$thread['price'] , $thread[itemid]
其中:$thread['blog']应该是主题是否允许加入BLOG..$lastmod['modaction']应该是操作纪 录,$thread['readperm']应该是帖子的阅读权限,而$thread[itemid]应该是什么呢?... $thread['price'] != 0为帖子交易积分不为0..
当上面任意一个变量存在的时候,开始执行下面的语句了吧..
        <tr class="category"><td colspan="2" align="center" class="bold">
  1. <!--{if $thread[itemid]}-->
  2.                 <a href="$supe_siteurl/index.php?action/viewspace/itemid/$thread[itemid]" target="_blank"><span class="bold" style="margin-right:20px;">{lang supe_thread_already_been_join_to_xspace}</span></a><!--{/if}-->
复制代码
..如果$thread[itemid]成立,则输出,已经加入到SS资讯里.从这里,可以推测出$thread[itemid]变量是控制判断DZ和SS之间的联系的.功能大概是,帖子是否已经导入SS中.
  1.         <!--{if $thread['special'] == '0' && $thread['price'] > 0}-->====如果主题交易积分不为0
  2.                   <a href="misc.php?action=viewpayments&tid=$tid">{lang price_thread} {$extcredits[$creditstrans][title]} <span class="bold">$thread[price]</span> {$extcredits[$creditstrans][unit]}</a>  ====浏览所需积分:其中: {$extcredits[$creditstrans][title]} 为论坛交易积分的ID
  3.         <!--{elseif $thread['special'] == 3}-->
  4.                   <span class="bold">
  5.                 <!--{if $thread['price'] > 0 }-->
  6.                         [{lang reward_unsolved}]====根据积分确定是否已经解决.
  7.                 <!--{elseif $thread['price'] < 0}-->
  8.                         [{lang reward_solved}]
  9.                 <!--{/if}-->
  10.                 {lang reward_thethread} {$extcredits[$creditstrans][title]} $rewardprice</span> {$extcredits[$creditstrans][unit]}</a> &nbsp;
  11.         <!--{/if}-->
复制代码
\
分析一下这个IF吧..
  1. <!--{if $lastmod['modaction']}-->  <a href="misc.php?action=viewthreadmod&tid=$tid" title="{lang thread_mod}" target="_blank">{lang thread_mod_by}</a> <!--{/if}-->
  2.         <!--{if $thread['blog']}-->  <a href="blog.php?uid=$thread[authorid]" target="_blank">{lang thread_blog}</a>  <!--{/if}-->
复制代码
帖子操作纪录
  1. <!--{if $thread['readperm']}-->  {lang readperm_thread} <span class="bold">$thread[readperm]</span>  <!--{/if}-->
  2.         </td></tr>
  3. <!--{/if}-->
复制代码
帖子阅读权限.
</table></div>
<form method="post" name="delpost" action="topicadmin.php?action=delpost&amp;fid=$fid&amp;tid=$tid&amp;page=$page">
<input type="hidden" name="formhash" value="{FORMHASH}">
<!--{loop $postlist $post}-->

        <div class="spaceborder" style="width: {TABLEWIDTH}; margin-bottom: 4px;<!--{if $post['first']}--> border-top: none<!--{/if}-->">
        <table cellspacing="{INNERBORDERWIDTH}" cellpadding="{TABLESPACE}" width="100%" align="center" class="t_row">
        <tr style="height: 100%">
        <td width="18%" valign="top" class="t_user">$post[newpostanchor] $post[lastpostanchor]
        <!--{if $forum['ismoderator']}-->
                <!--{if $allowviewip}--><a href="topicadmin.php?action=getip&amp;fid=$fid&amp;tid=$tid&amp;pid=$post[pid]"><img src="{IMGDIR}/ip.gif" border="0" align="right" alt="{lang admin_getip}" /></a><!--{/if}-->
        <!--{/if}-->
        <!--{if $post['authorid'] && $post['username'] && !$post['anonymous']}-->
                <a href="viewpro.php?uid=$post[authorid]" target="_blank" class="bold">$post[author]</a><!--{if $post['nickname']}--> <span class="smalltxt">($post[nickname])</span><!--{/if}-->
                <br><div class="smalltxt">
                $post[authortitle]
                <br>{eval showstars($post['stars']);}<br><!--{if $post['customstatus']}-->$post[customstatus]<br><!--{/if}--><br>
                <!--{if $avatarshowpos == 3 && $post['avatarshow'] && $showavatars}-->
                        <center>$post[avatarshow]</center><br>
                <!--{elseif $post['avatar'] && $showavatars}-->
                        <table width="95%" border="0" cellspacing="0" cellpadding="0" style="table-layout: fixed; overflow: hidden">
                        <tr><td align="center">$post[avatar]</td></tr></table><br>
                <!--{else}-->
                        <br><br>
                <!--{/if}-->
                <!--{if $post['medals']}-->
                        <!--{loop $post['medals'] $medal}-->
                                <img src="images/common/$medal[image]" border="0" alt="$medal[name]" /> &nbsp;
                        <!--{/loop}-->
                        <br>
                <!--{/if}-->
                {lang uid} $post[uid]<br>
                {lang digest_posts} <!--{if $post['digestposts']}--><a href="digest.php?authorid=$post[authorid]">$post[digestposts]</a><!--{else}-->$post[digestposts]<!--{/if}--><br>
                {lang credits} $post[credits]<br>
                {lang posts} $post[posts]<br>
                <!--{loop $extcredits_thread $key $credit}-->
                        $credit[title] $post[$key] $credit[unit]<br>
                <!--{/loop}-->
                {lang readperm} $post[readaccess]<br>
                {lang regtime} $post[regdate]
                <!--{loop $_DCACHE['fields_thread'] $field}-->
                        <br>$field[title]&nbsp;
                        <!--{if $field['selective']}-->
                                $field['choices'][$post['field_'.$field['fieldid']]]
                        <!--{else}-->
                                $post['field_'.$field['fieldid']]
                        <!--{/if}-->
                <!--{/loop}-->
                <!--{if $post['location']}--><br>{lang location} $post[location]<!--{/if}--><br>
                <!--{if $vtonlinestatus && $post['authorid']}-->
                        <!--{if ($vtonlinestatus == 2 && $onlineauthors[$post[authorid]]) || ($vtonlinestatus == 1 && ($timestamp - $post['lastactivity'] <= 10800) && !$post['invisible'])}-->
                                {lang online_status} <b>{lang online}</b>
                        <!--{else}-->
                                {lang online_status} {lang offline}
                        <!--{/if}-->
                <!--{/if}-->
                <!--{if $avatarshowpos == 2 && $showavatars}--><br><br><center>$post[avatarshow]</center><!--{/if}-->
                </div>
                <!--{if $post['alipay']}--><br><a href="https://www.alipay.com/payto         <!--{/if}-->
        </table></td></tr></table></div>
<!--{/loop}-->
</form>

相关文章: