吾知网

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 5252|回复: 0
打印 上一主题 下一主题

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

[复制链接]
跳转到指定楼层
楼主
发表于 2015-11-1 13:51:44 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
论坛首页是大家经常需要改动的一个页面,下面我就给大家分析一下这个页面的结构。
这个页面的静态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[setting][bbname]</a><em>»</em><a href="forum.php">{$_G[setting][navs][2][navname]}</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[0]</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}-->

这段代码的具体对应了页面中的:

有英文意思你就可以大体指导对应的页面元素了,当然你想作弊的话简单的修改下这里面的变量就可以了。
接下来就到了我们论坛最重要的部分了,版块类表展示区,这个区域的内容都包含在,
    <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[tid]">delete</a><!--{/if}-->
                                                                <a href="forum.php?mod=viewthread&tid=$data[tid]" target="_blank" class="xi2">$data[subject]</a></dt>
                                                                <dd>$data[message]</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[tid]">delete</a><!--{/if}-->· <a href="forum.php?mod=viewthread&tid=$data[tid]" target="_blank" class="xi2">$data[subject]</a></li>
                                        <!--{/loop}-->
                                        </ul>
                                </div>
                        </div>
                <!--{/if}-->


紧接着下面:<div class="fl bm">为具体的外框的开始

以下代码是蓝色底纹,版块标题,收缩框,版主展示区域的代码。
<div class="bm_h cl">
                                        <span class="o">
                                                <img id="category_$cat[fid]_img" src="{IMGDIR}/$cat[collapseimg]" title="{lang spread}" alt="{lang spread}" />
                                        </span>
                                        <!--{if $cat['moderators']}--><span class="y">{lang forum_category_modedby}: $cat[moderators]</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[fid]{/if}" style="{if $cat[extra][namecolor]}color: {$cat[extra][namecolor]};{/if}">$cat[name]</a></h2>
                                </div>

以下代码为每个版块信息的具体位置代码:
<div id="category_$cat[fid]"class="bm_c" style="$collapse['category_'.$cat[fid]]"></div>每个板块的具体信息是以table 框架展示的,根据每行的展示个数,做了不同的展示方式。
这一段内容大体包含了,板块图标,版块名称,今日主题数,今日回复数,最后发表等等等的信息,有时候在做模板的时候经常需要对着些信息做些改动。那你就需要掌握基本的页面技术了。我这里只简单的说一下他们的默认结构为以下代码。
<dl{if !empty($forum[extra][iconwidth]) && !empty($forum[icon])} style="margin-left: {$forum[extra][iconwidth]}px;"{/if}>
                                                                        <dt><a href="$forumurl"{if $forum[redirect]} target="_blank"{/if}{if $forum[extra][namecolor]} style="color: {$forum[extra][namecolor]};"{/if}>$forum[name]</a><!--{if $forum[todayposts] && !$forum['redirect']}--><em class="xw0 xi1" title="{lang forum_todayposts}"> ($forum[todayposts])</em><!--{/if}--></dt>
                                                                        <!--{if empty($forum[redirect])}--><dd><em>{lang forum_threads}: $forum[threads]</em>, <em>{lang forum_posts}: $forum[posts]</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[lastpost][tid]&goto=lastpost#lastpost" class="xi2"><!--{echo cutstr($forum[lastpost][subject], 30)}--></a> <cite>$forum[lastpost][dateline] <!--{if $forum['lastpost']['author']}-->$forum['lastpost']['author']<!--{else}-->$_G[setting][anonymoustext]<!--{/if}--></cite>
                                                                                        <!--{else}-->
                                                                                                <a href="forum.php?mod=redirect&tid=$forum[lastpost][tid]&goto=lastpost#lastpost">{lang forum_lastpost}: $forum[lastpost][dateline]</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一些自己想要的东西了。
以上就是这个文件的具体分析,希望对大家能有所帮助!

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|吾知网 ( 粤ICP备13013563号-1 )

GMT+8, 2024-4-24 16:38 , Processed in 1.093750 second(s), 8 queries , Memcache On.

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表