jekeyhui99 发表于 2015-11-1 13:51:44

Discuz! X2论坛首页discuz.htm修改指南


论坛首页是大家经常需要改动的一个页面,下面我就给大家分析一下这个页面的结构。
这个页面的静态htm地址为./template/default/forum/discus.htm文件。
首先页面的头部为,引进默认的头部文件代码:<!--{subtemplate common/header}-->
下面为:
<div id="pt" class="bm cl">
      <!--{if empty($gid) && $announcements}-->
      <div class="y">
                <div id="an">
                        <dl class="cl">
                              <dt class="z xw1">{lang announcements}: </dt>
                              <dd>
                                        <div id="anc"><ul id="ancl">$announcements</ul></div>
                              </dd>
                        </dl>
                </div>
                <script type="text/javascript">announcement();</script>
      </div>
      <!--{/if}-->
      <div class="z">
                <a href="./" class="nvhm" title="{lang homepage}">$_G</a><em>»</em><a href="forum.php">{$_G}</a>$navigation
      </div>
</div>

这部分为论坛的公告和nav导航部分。其中公告部分为<divclass="y"></div>中的代码,他做了右浮动,nav导航部分<div class="z"></div>中的一部分。接下来便是这个页面的主题部分:<div id="ct" />部分了。这个标签中涵盖了论坛首页的大部分内容。下面我们就来具体的分析下这个标签中的内容,首先出现的代码片段为:<!--{if empty($gid)}-->
                <div id="chart" class="bm bw0 cl">
                        <p class="chart z">{lang index_today}: <em>$todayposts</em><span class="pipe">|</span>{lang index_yesterday}: <em>$postdata</em><span class="pipe">|</span>{lang index_posts}: <em>$posts</em><span class="pipe">|</span>{lang index_members}: <em>$_G['cache']['userstats']['totalmembers']</em><!--{if $_G['setting']['lastmember']}--><span class="pipe">|</span>{lang welcome_new_members}: <em><a href="home.php?mod=space&username={echo rawurlencode($_G['setting']['lastmember'])}" target="_blank" class="xi2">$_G['setting']['lastmember']</a></em><!--{/if}--></p>
                        <div class="y">
                              <!--{if $_G['uid']}--><a href="home.php?mod=space&uid=$_G['uid']&do=thread&view=me" title="{lang my_posts}" class="xi2">{lang my_posts}</a><!--{/if}--><!--{if !empty($_G['setting']['search']['forum']['status'])}--><!--{if $_G['uid']}--><span class="pipe">|</span><!--{/if}--><a href="search.php?mod=forum&srchfrom=$newthreads&searchsubmit=yes" title="{lang show_newthreads}" class="xi2">{lang show_newthreads}</a><!--{/if}-->
                        </div>
                </div>
      <!--{/if}-->
这段代码的具体对应了页面中的:http://www.discuz.net/data/attachment/forum/201106/26/214325nmniygmgyzd4irat.png.thumb.jpg
有英文意思你就可以大体指导对应的页面元素了,当然你想作弊的话简单的修改下这里面的变量就可以了。接下来就到了我们论坛最重要的部分了,版块类表展示区,这个区域的内容都包含在,    <divclass="mn"></div>的div标签中。以下代码为论坛论坛热点,当后台开启后,此段代码便会显示<!--{if !empty($_G['cache']['heats']['message'])}-->
                        <div class="bm">
                              <div class="bm_h cl">
                                        <h2>{lang hotthreads_forum}</h2>
                              </div>
                              <div class="bm_c cl">
                                        <div class="heat z">
                                                <!--{loop $_G['cache']['heats']['message'] $data}-->
                                                      <dl class="xld">
                                                                <dt><!--{if $_G['adminid'] == 1}--><a class="d" href="forum.php?mod=misc&action=removeindexheats&tid=$data">delete</a><!--{/if}-->
                                                                <a href="forum.php?mod=viewthread&tid=$data" target="_blank" class="xi2">$data</a></dt>
                                                                <dd>$data</dd>
                                                      </dl>
                                                <!--{/loop}-->
                                        </div>
                                        <ul class="xl xl1 heatl">
                                        <!--{loop $_G['cache']['heats']['subject'] $data}-->
                                                <li><!--{if $_G['adminid'] == 1}--><a class="d" href="forum.php?mod=misc&action=removeindexheats&tid=$data">delete</a><!--{/if}-->· <a href="forum.php?mod=viewthread&tid=$data" target="_blank" class="xi2">$data</a></li>
                                        <!--{/loop}-->
                                        </ul>
                              </div>
                        </div>
                <!--{/if}-->

紧接着下面:<div class="fl bm">为具体的外框的开始http://www.discuz.net/data/attachment/forum/201106/26/214325onncb9n9bewqe39o.png.thumb.jpg
以下代码是蓝色底纹,版块标题,收缩框,版主展示区域的代码。<div class="bm_h cl">
                                        <span class="o">
                                                <img id="category_$cat_img" src="{IMGDIR}/$cat" title="{lang spread}" alt="{lang spread}" />
                                        </span>
                                        <!--{if $cat['moderators']}--><span class="y">{lang forum_category_modedby}: $cat</span><!--{/if}-->
                                        <!--{eval $caturl = !empty($cat['domain']) && !empty($_G['setting']['domain']['root']['forum']) ? 'http://'.$cat['domain'].'.'.$_G['setting']['domain']['root']['forum'] : '';}-->
                                        <h2><a href="{if !empty($caturl)}$caturl{else}forum.php?gid=$cat{/if}" style="{if $cat}color: {$cat};{/if}">$cat</a></h2>
                              </div>
以下代码为每个版块信息的具体位置代码:<div id="category_$cat"class="bm_c" style="$collapse['category_'.$cat]"></div>每个板块的具体信息是以table 框架展示的,根据每行的展示个数,做了不同的展示方式。这一段内容大体包含了,板块图标,版块名称,今日主题数,今日回复数,最后发表等等等的信息,有时候在做模板的时候经常需要对着些信息做些改动。那你就需要掌握基本的页面技术了。我这里只简单的说一下他们的默认结构为以下代码。<dl{if !empty($forum) && !empty($forum)} style="margin-left: {$forum}px;"{/if}>
                                                                        <dt><a href="$forumurl"{if $forum} target="_blank"{/if}{if $forum} style="color: {$forum};"{/if}>$forum</a><!--{if $forum && !$forum['redirect']}--><em class="xw0 xi1" title="{lang forum_todayposts}"> ($forum)</em><!--{/if}--></dt>
                                                                        <!--{if empty($forum)}--><dd><em>{lang forum_threads}: $forum</em>, <em>{lang forum_posts}: $forum</em></dd><!--{/if}-->
                                                                        <dd>
                                                                        <!--{if $forum['permission'] == 1}-->
                                                                              {lang private_forum}
                                                                        <!--{else}-->
                                                                              <!--{if $forum['redirect']}-->
                                                                                        <a href="$forumurl" class="xi2">{lang url_link}</a>
                                                                              <!--{elseif is_array($forum['lastpost'])}-->
                                                                                        <!--{if $cat['forumcolumns'] < 3}-->
                                                                                                <a href="forum.php?mod=redirect&tid=$forum&goto=lastpost#lastpost" class="xi2"><!--{echo cutstr($forum, 30)}--></a> <cite>$forum <!--{if $forum['lastpost']['author']}-->$forum['lastpost']['author']<!--{else}-->$_G<!--{/if}--></cite>
                                                                                        <!--{else}-->
                                                                                                <a href="forum.php?mod=redirect&tid=$forum&goto=lastpost#lastpost">{lang forum_lastpost}: $forum</a>
                                                                                        <!--{/if}-->
                                                                              <!--{else}-->
                                                                                        {lang never}
                                                                              <!--{/if}-->
                                                                        <!--{/if}-->
                                                                        </dd>
                                                                </dl>
接下来便是在线人数和友情链接展示的区域代码:<div id="online" class="bmoll"></div>,<divclass="bm lk"></div>这两段代码我们一般不需要修改来我这里就不具体讲解了。接下来就是侧边栏了。<div id="sd" class="sd"></div>当我们开启侧边栏的时候他就会显示了。经常有人希望在侧边栏加些东西,这是我们就可以在这个标签底部加一段diy的标签,这样我们就可以diy一些自己想要的东西了。以上就是这个文件的具体分析,希望对大家能有所帮助!

页: [1]
查看完整版本: Discuz! X2论坛首页discuz.htm修改指南