慕容的工作随笔

慕容的工作随笔

记录学习和工作

discuz代码分析 forumdisplay.htm模板代码分析

代码:
{template header}
这个,大家都知道..是调用文件头模板..在这里,可以开始留意一下DISCUZ特有的一些函数..好比喻说..{template xxx} <!–{if xxx}–>等等,
引用:
<div class=“subtable” style=“width:{TABLEWIDTH}">
复制内容到剪贴板
代码:
<div class=“right” style=“margin-bottom: 5px;">
<!–{if $supe_status && $discuz_uid}–>
<!–{if !$xspacestatus}–>
<a href=“http://murongshuai.blog.163.com/$supe_siteurl/index.php?action/register" target="_blank”>{lang supe_signin_xspace}</a> |
<!–{else}–>
<a href=“http://murongshuai.blog.163.com/$supe_siteurl/index.php?action/space/uid/$discuz_uid" target="_blank”>{lang supe_myxspace}</a> |
<!–{/if}–>
<!–{/if}–>
右上角:个人空间:如果还没有个人空间的,则显示{lang supe_signin_xspace}如果已经有个人空间的.显示:{lang supe_myxspace}
复制内容到剪贴板
代码:
<a href=“http://murongshuai.blog.163.com/my.php?item=favorites&amp;favadd=$fid&amp;type=forum"&gt;{lang forum_favorite}</a> |
收藏本版
复制内容到剪贴板
代码:
<a href=“http://murongshuai.blog.163.com/my.php?item=threads&amp;srchfid=$fid"&gt;{lang show_mytopics}</a>
我的话题
复制内容到剪贴板
代码:
<!–{if $allowmodpost && $forum[‘modnewposts’]}–>
| <a href=“http://murongshuai.blog.163.com/admincp.php?action=modthreads&amp;frames=yes" target="_blank”>{lang forum_moderate}{lang forum_moderate_threads}</a>
<!–{if $forum[‘modnewposts’] == 2}–>| <a href=“http://murongshuai.blog.163.com/admincp.php?action=modreplies&amp;frames=yes" target="_blank”>{lang forum_moderate}{lang forum_moderate_replies}</a><!–{/if}–>
<!–{/if}–>
…这个是后台设置需要审核发贴后,版主进入后看到的审核,新主题,新回复
复制内容到剪贴板
代码:
<!–{if $adminid == 1 && $forum[‘recyclebin’]}–>
| <a href=“http://murongshuai.blog.163.com/admincp.php?action=recyclebin&amp;frames=yes" target="_blank”>{lang forum_recyclebin}</a>
<!–{/if}–>
..如果后台设置该版有回收站,并且有管理权限,则显出回收站
复制内容到剪贴板
代码:
<!–{if $rssstatus}–><a href=“http://murongshuai.blog.163.com/rss.php?fid=$fid&amp;auth=$rssauth" target="_blank”><img src=“http://murongshuai.blog.163.com/images/common/xml.gif" border=“0” class=“absmiddle” alt="{lang rss_subscribe_all}” /></a><!–{/if}–>
..RSS收录
</div>
复制内容到剪贴板
代码:
<div class=“nav”><!–{if $forumjump && $jsmenu[1]}–><span id=“forumlist”><a href=“http://murongshuai.blog.163.com/$indexname"&gt;$bbname&lt;/a&gt;&lt;script type=“text/javascript”>menuregister(false, “forumlist”)</script></span><!–{else}–><a href=“http://murongshuai.blog.163.com/$indexname"&gt;$bbname&lt;/a&gt;&lt;!--{/if}--> $navigation</div>
</div></div>..

如果后台开启论坛跳转和JS菜单,则显示移动到论坛名字后出现下拉菜单的效果
紧接着..
引用:
<div class=“maintable”>
<div class=“subtable outertxt” style=“width: {TABLEWIDTH}; margin-top: 5px; clear: both;">
<div class=“right”>
复制内容到剪贴板
代码:
<!–{if $searchboxstatus}–>
<form method=“post” action=“search.php?srchtype=qihoo” onSubmit=“this.target=’blank’;">
<input type=“hidden” name=“searchsubmit” value=“yes”>
<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()">
<!–{if $qihoo_allsearch != ‘2’}–><input name=“searchsubmit” class=“button” type=“submit” value="{lang search}"><!–{/if}–>
<!–{if $qihoo_allsearch}–>
<input name=“allsearchsubmit” class=“button” type=“submit” value="{lang qihoo_search}">
<!–{/if}–>
</form>
<!–{/if}–>
…显示QIHOO垃圾搜索的代码</div>
复制内容到剪贴板
代码:
{lang forum_modedby}:
<!–{if $moderatedby}–>$moderatedby<!–{else}–>{lang forum_opening}<!–{/if}–>
如果该版有版主则输出.版主,(这里的$moderatedby是一个变量,是承继由FORUMDISPLAY.PHP下来的,上面已经设定好这变量怎样 输出的了.)否则,输出:{lang forum_opening},相关的lang大家可以到templates.lang.php中查 到.</div><br></div>
呵呵,是不是很简单呢..
下面继续..
引用:
复制内容到剪贴板
代码:
<!–{if $forum[‘rules’]}–>
<div class=“maintable”>
<div class=“spaceborder” style=“width: {TABLEWIDTH}">
<table cellspacing="{INNERBORDERWIDTH}” cellpadding="{TABLESPACE}” width=“100%” align=“center”>
<tr class=“header”><td>
以下内容为程序代码:<a href=“http://murongshuai.blog.163.com/###" onclick=“toggle_collapse(‘rules
$fid’);"><img id=“rules_{$fid}img” src=“http://murongshuai.blog.163.com/{IMGDIR}/$rulescollapseimg" align=“right” border=“0” alt=”” /></a>这里就是那个点击打开或者关闭的选项了.{lang forum_rules}</td></tr>
<tbody id=“rules
$fid” style="$collapserules”>
<tr><td class=“altbg2 bottom”>$forum[rules]</td></tr>
</tbody></table></div><br>
</div>
<!–{/if}–>
如果设置了版规,则显示出来.留意一下:$forum[rules],这个就是版规的内容..具体输出是在forumdisplay.php已经设定好了的.
..其实我刚刚看的时候..好多都不明白…以前一直是用开PHPWIND,转过来,发现,好多都不一样了..废话少说..继续..
引用:
<!–{if !empty($newpmexists)}–>
<div class=“maintable”>
{template pmprompt}
</div>
<!–{/if}–>
如果有新短信,则调用短信pmprompt.htm这个模板..对于新手来说..DISCUZ有个最明显的调用..就是{template xxx},可以在自己喜欢的地方随便再插入另一个模板..非常方便啊..
NEXT…
引用:

<!–{if $subexists}–>
<div class=“maintable”>
{template forumdisplay_subforum}
</div>
<!–{/if}–>
..如果这个版块含有分版,则调用分版模块..也就是说..要美化分版..要找到forumdisplay_subforum.htm就OK了.
NEXT..
引用:
复制内容到剪贴板
代码:
<!–{if !empty($advlist[’text’])}–>
<div class=“maintable”>
<div class=“spaceborder” style=“width: {TABLEWIDTH}">
<table cellspacing=“1” border=“0” cellpadding="{TABLESPACE}” width=“100%” style=“background: {BGBORDER}">$advlist[text]</table>
</div><br></div>
<!–{/if}–>
如果这个版设罢了广告,则输出广告分栏。。这个变量$advlist[text]。。是整个广告输出,同样地是由上面继承下来的。。下次再详细的分析。。
NEXT。。。
引用:
<div class=“maintable” style=“clear:both”>
<table width="{TABLEWIDTH}” cellspacing=“0” cellpadding=“0” align=“center” style=“margin-bottom: {TABLESPACE}px”>
复制内容到剪贴板
代码:
<tr><td valign=“bottom”>$multipage</td>
呵呵,在这里,说说这个$multipage吧。。我刚才分析了一下。。大家可以看这里
http://www.discuz.net/thread-459746-1-2.html

<td align=“right” valign=“bottom”>
复制内容到剪贴板
代码:
<!–{if $allowpost || !$discuz_uid}–>
。。。如果允许发贴并且是会员。。则显示出发贴菜单(下拉)
<div id=“newspecialheader” class=“right”><a href=“http://murongshuai.blog.163.com/post.php?action=newthread&amp;fid=$fid&amp;extra=$extra"&gt;&lt;img src=“http://murongshuai.blog.163.com/{IMGDIR}/newtopic.gif" border=“0” class=“absmiddle” alt=”” /></a><a href=“http://murongshuai.blog.163.com/###"&gt;&lt;img src=“http://murongshuai.blog.163.com/{IMGDIR}/newspecial.gif" border=“0” class=“absmiddle” alt=”” /></a><script type=“text/javascript”>menuregister(false, “newspecialheader”, true)</script></div>
<!–{if ($allowposttrade && $ec_id) || $allowpostpoll || $allowpostreward || $allowpostactivity || !$discuz_uid}–>
<div class=“popupmenu_popup newspecialmenu” id=“newspecialheader_menu” style=“display: none”>
<table cellpadding=“4” cellspacing=“0” border=“0” width=“100%">
复制内容到剪贴板
代码:
<!–{if $allowpostpoll || !$discuz_uid}–><tr><td class=“popupmenu_option”><div class=“newspecial”><a href=“http://murongshuai.blog.163.com/post.php?action=newthread&amp;fid=$fid&amp;extra=$extra&amp;poll=yes"&gt;{lang thread_poll}</a></div></td></tr><!–{/if}–>
投票
复制内容到剪贴板
代码:
<!–{if ($allowposttrade && $ec_id) || !$discuz_uid}–><tr><td class=“popupmenu_option”><div class=“newspecial”><a href=“http://murongshuai.blog.163.com/post.php?action=newthread&amp;fid=$fid&amp;extra=$extra&amp;trade=yes"&gt;{lang thread_trade}</a></div></td></tr><!–{/if}–>
交易
复制内容到剪贴板
代码:
<!–{if $allowpostreward || !$discuz_uid}–><tr><td class=“popupmenu_option”><div class=“newspecial”><a href=“http://murongshuai.blog.163.com/post.php?action=newthread&amp;fid=$fid&amp;extra=$extra&amp;reward=yes"&gt;{lang thread_reward}</a></div></td></tr><!–{/if}–>
悬赏
复制内容到剪贴板
代码:
<!–{if $allowpostactivity || !$discuz_uid}–><tr><td class=“popupmenu_option”><div class=“newspecial”><a href=“http://murongshuai.blog.163.com/post.php?action=newthread&amp;fid=$fid&amp;extra=$extra&amp;activity=yes"&gt;{lang thread_activity}</a></div></td></tr><!–{/if}–>
活动        </table></div>
<!–{/if}–>下拉结束。。
<!–{/if}–>
</td></tr></table></div>

<div class=“maintable”>
<div class=“spaceborder” style=“width: {TABLEWIDTH}; border-bottom: none”><table cellspacing="{INNERBORDERWIDTH}” cellpadding="{TABLESPACE}” width=“100%">
复制内容到剪贴板
代码:
<tr class=“header”><td colspan=“6”><table width=“100%” cellspacing=“0” cellpadding=“0”><tr><td><a href=“http://murongshuai.blog.163.com/forumdisplay.php?fid=$fid" class=“bold”>$forum[name]</a></td><td align=“right”>
这个就是帖子列表上面的版块名字了。。
复制内容到剪贴板
代码:
<a href=“http://murongshuai.blog.163.com/forumdisplay.php?fid=$fid"&gt;{lang forum_viewall}</a>
右边的“全部”
复制内容到剪贴板
代码:
<!–{if $filter == ‘digest’}–><span class=“bold”>{lang thread_digest}</span><!–{else}–><a href=“http://murongshuai.blog.163.com/forumdisplay.php?fid=$fid&amp;filter=digest"&gt;{lang thread_digest}</a><!–{/if}–>
精华
复制内容到剪贴板
代码:
<!–{if $showpoll}–><!–{if $filter == ‘poll’}–><span class=“bold”>{lang thread_poll}</span><!–{else}–><a href=“http://murongshuai.blog.163.com/forumdisplay.php?fid=$fid&amp;filter=poll"&gt;{lang thread_poll}</a><!–{/if}–><!–{/if}–>
如果这版允许投票,则显示投票选项
复制内容到剪贴板
代码:
<!–{if $showtrade && $ec_id}–><!–{if $filter == ’trade’}–><span class=“bold”>{lang thread_trade}</span><!–{else}–><a href=“http://murongshuai.blog.163.com/forumdisplay.php?fid=$fid&amp;filter=trade"&gt;{lang thread_trade}</a><!–{/if}–><!–{/if}–>
如果这版允许交易,则曗交易
复制内容到剪贴板
代码:
<!–{if $showreward}–><!–{if $filter == ‘reward’}–><span class=“bold”>{lang thread_reward}</span><!–{else}–><a href=“http://murongshuai.blog.163.com/forumdisplay.php?fid=$fid&amp;filter=reward"&gt;{lang thread_reward}</a><!–{/if}–><!–{/if}–>
其它。。
复制内容到剪贴板
代码:
<!–{if $showactivity}–><!–{if $filter == ‘activity’}–><span class=“bold”>{lang thread_activity}</span><!–{else}–><a href=“http://murongshuai.blog.163.com/forumdisplay.php?fid=$fid&amp;filter=activity"&gt;{lang thread_activity}</a><!–{/if}–>
活动<!–{/if}–>
<!–{if $forum[’threadtypes’] && $forum[’threadtypes’][’listable’]}–>
<!–{loop $forum[’threadtypes’][‘flat’] $id $name}–><!–{if $typeid != $id}–><a href=“http://murongshuai.blog.163.com/forumdisplay.php?fid=$fid&amp;filter=type&amp;typeid=$id"&gt;$name&lt;/a&gt;&lt;!--{else}--&gt;&lt;span class=“bold”>$name</span><!–{/if}–> <!–{/loop}–>
<!–{if $forum[’threadtypes’][‘selectbox’]}–>
复制内容到剪贴板
代码:
<span id=“threadtypesmenu”><a href=“http://murongshuai.blog.163.com/###"&gt;{lang admin_type_more} …<script type=“text/javascript”>menuregister(false, “threadtypesmenu”, true)</script></a></span>
更多分类
<div class=“popupmenu_popup” id=“threadtypesmenu_menu” style=“display: none”>
<table cellpadding=“4” cellspacing=“0” border=“0” width=“50”>
复制内容到剪贴板
代码:
<!–{loop $forum[’threadtypes’][‘selectbox’] $id $name}–>
<tr><td class=“popupmenu_option” align=“center”>

以下内容为程序代码:<!–{if $typeid != $id}–>                                 <a href=“http://murongshuai.blog.163.com/forumdisplay.php?fid=$fid&amp;filter=type&amp;typeid=$id&amp;sid=$sid"&gt;$name&lt;/a>                         <!–{else}–>                                 <span class=“bold” style=“color: {TEXT}">$name</span>                         <!–{/if}–></td></tr>
<!–{/loop}–>
循环输出论坛主题分类
</table></div>
<!–{/if}–>
<!–{/if}–>
</td></tr></table></td></tr>
复制内容到剪贴板
代码:
<tr class=“category”>
<td width=“4%"> </td>
<td width=“25”> </td>
<td width=“55%” align=“left”>{lang subject}</td>
<td width=“12%” align=“center”>{lang author}</td>
<td width=“8%” align=“center”>{lang replies}/{lang views}</td>
<td width=“17%” align=“center”>{lang lastpost}</td>
</tr>
..主题分类下面的一行表格..帖子标题..作者..查看次数/回复资料 最后发表..
复制内容到剪贴板
代码:
<!–{if $page == 1 && !empty($announcement)}–>
..在第一页,并且公告内容不为空的情况下,输出论坛公告..
复制内容到剪贴板
代码:
<tr class=“row” onMouseOver=“this.className=‘row1’” onMouseOut=“this.className=‘row’">
在这里,开始提醒大家留意一下这个:
复制内容到剪贴板
代码:
onMouseOver=“this.className=‘row1’” onMouseOut=“this.className=‘row’
这个功能是..鼠标移上去就采用row1样式..移出就采用row样式..可以查看css.htm里相应的设置..就是鼠标划过后变色的效果..可以参照这个,用到其它地方去..
DISCUZ里很多地方都是这样的,很多地方是通用的..呵呵..
<td align=“center”>
复制内容到剪贴板
代码:
<!–{if empty($announcement[‘redirect’])}–><a href=“http://murongshuai.blog.163.com/announcement.php?id=$announcement[id]#$announcement[id]" target="_blank”><!–{else}–><a href=“http://murongshuai.blog.163.com/$announcement[message]" target="_blank”><!–{/if}–>
公告类型: 文字公告..
<img src=“http://murongshuai.blog.163.com/{IMGDIR}/lock_folder.gif" border=“0” alt=”” /></a></td>
<td colspan=“2”>{lang announcement}:
复制内容到剪贴板
代码:
<!–{if empty($announcement[‘redirect’])}–><a href=“http://murongshuai.blog.163.com/announcement.php?id=$announcement[id]#$announcement[id]" target="_blank”>$announcement[subject]</a><!–{else}–><a href=“http://murongshuai.blog.163.com/$announcement[message]" target="_blank”>$announcement[subject]</a><!–{/if}–>
公告类型..网址链接..其中:$announcement[subject]就是公告标题了..
</td>
复制内容到剪贴板
代码:
<td align=“center”><a href=“http://murongshuai.blog.163.com/viewpro.php?uid=$announcement[authorid]"&gt;$announcement[author]&lt;/a&gt;&lt;br&gt;&lt;span class=“smalltxt”>$announcement[starttime]</span></td>
公告作者..发布时间..
<td align=“center”>-</td>
<td align=“center”>-</td>
</tr>
<!–{/if}–>
</table></div></div>

代码:
<form method=“post” name=“moderate” action=“topicadmin.php?action=moderate&fid=$fid”>
<input type=“hidden” name=“formhash” value="{FORMHASH}">
..下面是整个帖子列表的输出,但同时,如果有管理权限的,会出现管理的功能..于是..需要套用整个FORM来提交管理数据..
<!–{if $threadcount}–>
<div class=“maintable”><div class=“spaceborder” style=“width: {TABLEWIDTH}; border-top: none;border-bottom: none”>
<!–{loop $threadlist $key $thread}–>
<table cellspacing="{INNERBORDERWIDTH}” cellpadding="{TABLESPACE}” class=“row”   >
<!–{if $separatepos == $key + 1}–>
<tr class=“category”><td> </td><td colspan=“6”>{lang forum_normal_threads}</td></tr>
<!–{/if}–>
<tr>
复制内容到剪贴板
代码:
<td class=“f_folder”><a href=“http://murongshuai.blog.163.com/viewthread.php?tid=$thread[tid]" target="_blank”><img src=“http://murongshuai.blog.163.com/{IMGDIR}/$thread[folder]" border=“0” alt=”” /></a></td>
帖子列表最前面的图标:$thread[folder]这个参数控制..一般有lock_folder.gif,red_folder.gif等等..
复制内容到剪贴板
代码:
<td class=“f_icon”>$thread[‘icon’]</td>
这个..就是发帖子的时候选择的图标ICON..
<td class=“f_title”>
<div class=“right”>
复制内容到剪贴板
代码:
<!–{if $thread[‘rate’] > 0}–>
<img src=“http://murongshuai.blog.163.com/{IMGDIR}/agree.gif" alt=”” />
<!–{elseif $thread[‘rate’] < 0}–>
<img src=“http://murongshuai.blog.163.com/{IMGDIR}/disagree.gif" alt=”” />
<!–{/if}–>
评分大于0,则agree.gif否则输出disagree.gif,留意一个atl=”’.这个是控制鼠标移上去后出现的提示..
复制内容到剪贴板
代码:
<!–{if $thread[‘special’] == 1}–>
<img src=“http://murongshuai.blog.163.com/{IMGDIR}/pollsmall.gif" alt="{lang thread_poll}” />
<!–{/if}–>
..控制投票图标,其中的$thread[‘special’]==1投票,==2为交易.==3悬赏.==4活动
复制内容到剪贴板
代码:
<!–{if $thread[‘special’] == 2}–>
<img src=“http://murongshuai.blog.163.com/{IMGDIR}/tradesmall.gif" alt="{lang thread_trade}” />
<!–{/if}–>
同上面..
复制内容到剪贴板
代码:
<!–{if $thread[‘special’] == 3}–>
<!–{if $thread[‘price’] > 0}–>
<img src=“http://murongshuai.blog.163.com/{IMGDIR}/rewardsmall.gif" alt="{lang thread_reward}” />====悬赏开始
<!–{elseif $thread[‘price’] < 0}–>
<img src=“http://murongshuai.blog.163.com/{IMGDIR}/rewardsmallend.gif" alt="{lang thread_rewardend}” />====悬赏结束
<!–{/if}–>
<!–{/if}–>
加入了悬赏是否结束的判断
复制内容到剪贴板
代码:
<!–{if $thread[‘special’] == 4}–>
<img src=“http://murongshuai.blog.163.com/{IMGDIR}/activitysmall.gif" alt="{lang thread_activity}” />
<!–{/if}–>
活动
复制内容到剪贴板
代码:
<!–{if $thread[‘attachment’]}–>
<img src=“http://murongshuai.blog.163.com/images/attachicons/common.gif" alt="{lang attachment}” />
<!–{/if}–>

是否有附件..
复制内容到剪贴板
代码:
<!–{if $thread[‘displayorder’]}–>
<img src=“http://murongshuai.blog.163.com/{IMGDIR}/pin_$thread[displayorder].gif" alt="$threadsticky[3-$thread[displayorder]]” />
<!–{/if}–>
置顶1,2,3级..,由pin_$thread[displayorder].gif控制..
复制内容到剪贴板
代码:
<!–{if $thread[‘digest’]}–>
<img src=“http://murongshuai.blog.163.com/{IMGDIR}/digest_$thread[digest].gif" alt="{lang thread_digest} $thread[digest]” />
<!–{/if}–>

精华..一级,二级..三级..由digest_$thread[digest].gif控制..
</div>
<span class=“lighttxt”>
复制内容到剪贴板
代码:
<!–{if $forum[‘ismoderator’]}–>
<!–{if $thread[‘fid’] == $fid}–>
<input class=“checkbox” type=“checkbox” name=“moderate[]” value="$thread[tid]">
<!–{else}–>
<input class=“checkbox” type=“checkbox” disabled>
<!–{/if}–>
<!–{/if}–>
如果有管理权限..则在标题前面加个可选框(也就是打勾的那个),选上后进行管理..
复制内容到剪贴板
代码:
<!–{if $thread[‘moved’]}–>
<!–{if $forum[‘ismoderator’]}–>
<a href=“http://murongshuai.blog.163.com/topicadmin.php?action=delete&amp;tid=$thread[moved]"&gt;{lang thread_moved}:</a>
<!–{else}–>
{lang thread_moved}:
<!–{/if}–>
<!–{/if}–>
复制内容到剪贴板
代码:
$thread[typeid]
标题前的帖子分类..</span>
复制内容到剪贴板
代码:
<a href=“http://murongshuai.blog.163.com/viewthread.php?tid=$thread[tid]&amp;extra=$extra"$thread[highlight]&gt;$thread[subject]&lt;/a>
输出帖子标题,留意一下viewthread.php?tid=$thread[tid]&extra=$extra”$thread[highlight]中的$thread[highlight],将控制帖子的高亮显示..
<span class=“lighttxt”>
复制内容到剪贴板
代码:
<!–{if $thread[‘readperm’]}–> - [{lang readperm} <span class=“bold”>$thread[readperm]</span>]<!–{/if}–>

 

评论 (0)

还没有评论,来做第一个吧。

发表评论

提交后需管理员审核通过后显示