Home > php教程 > PHP开发 > Discuz template statement analysis and knowledge skills

Discuz template statement analysis and knowledge skills

黄舟
Release: 2016-12-14 13:29:35
Original
1377 people have browsed it

1. Template calling
For example, in a template, if you want to call the content in another template, you can use the following statement:
{template xxx}
Suppose that a new template named "abc.htm" is created. When the background template is edited, it will only be displayed as "acb". If you need to call it in the index, then add {template abc} to the appropriate position in the index and it will be automatically used.

Related examples: In the index template, there is {template header} at the top and {template footer} at the bottom.
Related questions:
Then in this abc template, there needs to be ?
Unnecessary! Just write whatever you want to display, because it is only a part of the entire web page! are already in the header and footer templates.


2. Fixed parameters
$seohead --- Header information of background settings
$charset --- The language character set is set in config.inc.php. It is essential and cannot be deleted!
$extrahead --- Control forum automatic jump parameters, essential, cannot be deleted!
{eval updatesession();} --- Update the parameters of the forum session table. It is essential and cannot be deleted!
{eval output();} --- End the forum output, it is essential and cannot be deleted!

The above parameters are based on Discuz! 4.0. These parameters will vary according to different versions!
There are also some parameters of $xxx. If you are not a plug-in author or program developer, please do not modify them randomly!


3. Data Judgment
1. You will often see xxxxx statement.
These are not comments in ordinary HTML, but Discuz!'s unique template judgment syntax, just like if, else, then, etc. in PHP or other syntaxes.
Through these syntaxes, different template effects can be achieved.

Related examples:

Copy content to the clipboard in

header template

Code:

--- If $discuz_uid is obtained, the following information will be displayed ( Judgment 1)

$discuz_userss: {langlogo ut}

--- If there is $maxpmnum, the following information will be displayed, otherwise it will not be displayed (Judgment 2)
| {lang pm }
--- Ended this judgment (judgment 2)

| {lang memcp}

--- If $adminid is within the range of 1,2,3 , that is, the following information will be displayed, otherwise it will not be displayed (Judgment 3)
| {lang admincp}
--- Ended this judgment (Judgment 3)

--- If $discuz_uid cannot be obtained, the following information will be displayed

{lang guest}: {lang register}
| {lang login}

--- End this judgment (judgment 1)

2. You will often see xxx statement.

This is a loop statement, which will automatically end until the data is output.
Through these syntaxes, the same series of data can be displayed in a loop.

Related examples:

Copy content to the clipboard in

header template

Code:

--- Loop 1 starts, Determine the plug-in

--- Loop 2 starts, judge the plug-in module
| $module[url]
--- End loop 2
--- End loop 1

4. Language call

In the template , you often see statements like {lang xxx}. It is used to call words in the language package.
Most of the things that are called in templates are templates.lang.php.
Let’s take a look at the structure of the language pack:

Copy the content to the clipboard

Code:

$language = array
( --- The above announcement is the start of the language pack definition

'title' => 'title',
Call characters to display text
'never' => 'Never',
Call the character to display text
....
); --- Declare the end of the language package definition
?> -- Declare the end of the php language

Related examples:
Suppose we add a language call, Add
'abc' => 'This is a test language call' in the line above
'title' => 'Title',
The last one is indispensable, as well as the calling characters and display text, both Must be quoted using ''.
After adding it, you can call it in the template. Write {lang abc} in the template
Then it will be displayed directly: This is a test language call


Special note: After adding a language or modifying a language package, the cache must be updated oh!


5. Style Parameter Calling
The statements {XXXXX} are often seen in templates. {} must be in uppercase letters.

These are the parameters in the calling style color scheme. You can add it yourself, the method is as follows:
1. Enter the interface style-> Interface style-> the style point where you want to add parameters [Details]
2. At the bottom after entering, there are two columns to fill in, one is variables , one is to replace the content

Related examples:
Write FOOTERCOLOR for the variable (note that you must use uppercase letters)
Write #003399 for the replacement content
After submission, modify the template and write Test style in the template Custom variable
The result is that this test style custom variable will be displayed according to the color of the filled-in replacement content.
After what has been said above, you should know a lot about what you need to pay attention to or what can be applied when modifying the template!

Hope it is helpful to you. For more related content, please pay attention to the PHP Chinese website (www.php.cn)!


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template