<p>

前段时间做了个简单的Q2A主题,有朋友留言说比较乱,于是决定写一篇简单的说明供大家参考,想到哪儿写到哪儿,稍微有点乱。

</p>
<p>

主题快捷传送门:<a href="//feifei.im/archives/60">https://feifei.im/archives/60</a> 

</p>
<p>

一.“qa-theme.php”为重写的主题文件,它继承自“qa-include\qa-theme-base.php”

</p>

<?php
class qa_html_theme extends qa_html_theme_base
{

<p>

二.页面html声明

</p>

function doctype()
   {
        $this->output('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd";>');
   }

<p>

三.声明html标签

</p>

function html()
    {
        $this->output('<HTML>');
        $this->head();    //引用头部信息
        $this->body();    //引用主体body部分信息
        $this->output('</HTML>');
    }

<p>

注:以上几个声明即组成了简单的html页面,即:

</p>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd";>
<HTML>
<HEAD>
</HEAD>
<BODY>
</BODY>
</HTML>

<p>

<strong>其中:</strong>

</p>
<p>

1.$this-&gt;head();调用的是下面的“function head()”(这个方法在qa-theme-base.php中,也可以自己复制到自己的qa-theme.php中重写结构样式);$this-&gt;body();与此类似

</p>
<p>

2.$this-&gt;output()的作用是原样输出括号中的字符串到页面

</p>


<p>

其他方法与此相似,需要注意的是,载入是<strong>按书写顺序来的</strong>,就是先载入head后载入body,要是调换两个引用的位置,加载的顺序也就相应调换了。

</p>
<p>

此外,调用自己的js可以用最简单的方法,就是用$this-&gt;output直接输出,如

</p>

$this-&gt;output(&#39;&lt;SCRIPT TYPE=&quot;text/javascript&quot; SRC=&quot;&#39;.$this->rooturl.$this->commonjs_name().'"></SCRIPT>');
function commonjs_name() { return 'qa-jianguocommon.js?'.QA_VERSION; }

例如,实现本主题的头部代码对应调用方法示意图
0000.png

通过

function header()
    {
    $this->output('<DIV ID="pageheader" CLASS="header"><DIV CLASS="header-box">');
    $this->logo();
    $this->search();
    $this->nav('main');
    $this->nav('user');
    $this->nav('sub');
    $this->header_clear();
    $this->output('</DIV></DIV> <!-- END header -->', '');

分别调用相应的结构样式