Discuz Template Statement analysis and knowledge skill _php skills

Source: Internet
Author: User

One, template call
For example, in a template, to invoke the contents of another template, you can use the following statement:
{Template XXX}
Suppose that a new template was established named "Abc.htm", inBackgroundTemplate editing will only appear as "ACB", you need to call it in index, then add {Template ABC} to the appropriate position in index
Then it will be automatically substituted.

Related examples:The index template has the top {Template header}, with the bottom {template footer}
Related questions:
Do you need to have No need! What you want to show is what you write, because it's just part of the whole page!

second, fixed parameters
$seohead---BackstageSet upThe head information
$charset---config.inc.php set the language character set, is essential, cannot delete!
$extrahead---ControlForum automatic jump parameters, essential, can not be deleted!
{eval updatesession ();} ---update the forum session table parameters, essential, can not be deleted!
{eval output ();} ---End of the forum output, essential, can not be deleted!

The above parameters are subject to Discuz ! 4.0, these parameters will vary according to different versions!
There are some $xxx also some parameters such as non- plugin author or program development do not mess up!


Third, data judgment
1, in the template will often see the <!--{if xx}-->xxx<!--{else}-->xx<!--{/if}--> statements.
These are not annotations in normal HTML , but rather discuz! specific template-judging syntax, like php or if,else,then in other grammars, and so on.
With these syntax, you can achieve different template effects.

Related examples:
Header template

Copy Content to Clipboard

Code :

<!--{if $discuz _uid}-->---If a $discuz _uid is obtained, the following information is displayed (Judge 1)
<span class= "Bold" > $discuz _userss: </span> <a href= "$link _logout" >{langLogoUt}</a>

<!--{if $maxpmnum}-->---if there is a $maxpmnum, that is to show the following information, otherwise not shown (Judge 2)
| <a href= "pm.php" target= "_blank" >{lang pm}</a>
<!--{/if}-->---ended this judgment (Judge 2)

| <a href= "memcp.php" >{lang memcp}</a>

<!--{if In_array ($adminid, Array (1,2,3))}-->---if $adminid within the three ranges of 1,2,3, that is to show the following information, otherwise not shown (Judge 3)
| <a href= "admincp.php" target= "_blank" >{lang admincp}</a>
<!--{/if}-->---ended this judgment (Judge 3)

<!--{else}-->---If you cannot get $discuz _uid, display the following information

<span class= "Bold" >{lang Guest}: </span><a href= "$link _register" >{lang register}</a>
| <a href= "$link _login" >{lang login}</a>

<!--{/if}-->---End this judgment (Judge 1)

2, in the template will often see the <!--{loop xx}-->xxx<!--{/loop}--> statements.
This is a circular statement until the output of the data is finished and automatically ends.
Through these grammars, can achieve the same series of data loop display effect.

Related examples:
Header Template

Copy Content to Clipboard

Code:

<!--{loop $plugins['links'] $plugin}--> --- 循环1开始,判断插件
        <!--{loop $plugin $module}--> --- 循环2开始,判断插件模组
             <!--{if !$module['adminid'] || ($module['adminid'] && $adminid > 0 && $module['adminid'] >= $adminid)}-->| $module[url] <!--{/if}-->
        <!--{/loop}--> --- 结束循环2
<!--{/loop}--> --- 结束循环1

Four, language call
In the template, you will often see statements such as {lang xxx}. It is used to invoke the words in the language pack.
Most of the calls in the template are templates.lang.php.
Here's a look at the structure of the language pack:

Copy Content to Clipboard

Code:

<?  -- 宣布php语言开始
$language = array
(                        --- 以上宣布语言包定义开始

        'title' => '标题',
        调用字符    显示文字
        'never' => '从未',
        调用字符    显示文字
        ....
); --- 宣告语言包定义结束
?>  -- 宣布php语言结束

Related instances:
Suppose that we add a language call, in the
' title ' => ' title ',
on the line add
' abc ' => ' This is the test language call ',
last, is more than essential, There are also call characters and display text that must be used to "cause".
added later, into the template, you can call it, write {lang abc}
in the template to display directly: This is the test language call


Special Note: Add a language or modify the language pack, you must update the cache Oh!


Five, style parameter calls
common to {XXXXX} statements in templates. The must be uppercase in {}.

These are parameters in the calling style color scheme. You can add it yourself, the method is as follows:
  1, enter the interface style-> interface style-> you want to add parameters to the style point [details]
  2, enter After the bottom, there are two columns can be filled out, one is a variable, one is the replacement of content

related instances:
    Variable write Footercolor (note must use uppercase)
    Replace content Write # 003399
After submitting, modify the template, write <font color= "{footercolor}" > Test style custom variable </font>
so out of effect, this test style custom variable will be displayed according to the color of the replacement content filled in.
after saying so much, to modify the template when you need to pay attention to or can be applied to should let you know a lot of!

would like to help you, Enjoy it!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.