Home > Backend Development > PHP Tutorial > Discuz template statement analysis and knowledge skills_PHP tutorial

Discuz template statement analysis and knowledge skills_PHP tutorial

WBOY
Release: 2016-07-21 15:44:22
Original
934 people have browsed it

  一、模板 调用
比如在某个模板中,想调用另一个模板中的内容,可以用下面的语句:
{template xxx}
假设,建立了一个新模板名字叫 "abc.htm" ,在后台 模板编辑时只会显示为 "acb",需要在 index 中调用它,那么就在index 中适当位置加入 {template abc}
那么就会自动代用它。

相关实例: index 模板中,最顶有 {template header},最底有 {template footer}
相关疑问:
那么在这个 abc 模板中需要有 吗?
不需要的!想要显示什么,就写什么,因为它只是整个网页的一部分! 都已经在header和footer模板中了。


二、固定参数
$seohead                        --- 后台设置 的头部信息
$charset                        --- config.inc.php中设置语言字符集,必不可少,不能删除!
$extrahead                        --- 控制论坛 自动跳转参数,必不可少,不能删除!
{eval updatesession();}                --- 更新论坛 session 表的参数,必不可少,不能删除!
{eval output();}                --- 结束论坛输出,必不可少,不能删除!

以上的参数以Discuz ! 4.0为准,这些参数会因应不同版本而有所不同!
还有一些 $xxx 的也是一些参数如非插件 作者或程序 开发请勿乱修改!


三、数据 判断
   1、在模板中会经常见到xxxxx的语句。
      这些并非普通HTML 中的注释,而是Discuz!特有的模板判断语法,就好比php 或者其他 语法中的 if,else,then等等。
      通过这些语法,能够达到不同的模板效果

相关实例:
header 模板中

复制内容到剪贴板
代码 :
<!--{if $discuz_uid}--> --- 如果获取了 $discuz_uid ,即显示下面资料(判断1)<br>        <span class="bold">$discuz_userss: </span> <a href="$link_logout">{lang<span class="t_tag">logo</span> ut}</a> <br><br>        <!--{if $maxpmnum}--> --- 如果有 $maxpmnum,即显示下面资料,否则不显示(判断2)<br>                | <a href="pm.php" target="_blank">{lang pm}</a> <br>        <!--{/if}--> --- 结束了这个判断(判断2) <br><br>        |  <a href="memcp.php">{lang memcp}</a> <br><br>        <!--{if in_array($adminid, array(1,2,3))}--> --- 如果$adminid在1,2,3这三个范围内,即显示下面资料,否则不显示(判断3)<br>                | <a href="admincp.php" target="_blank">{lang admincp}</a><br>        <!--{/if}--> --- 结束了这个判断(判断3) <br><br><!--{else}--> --- 如果获取不了 $discuz_uid ,则显示下面资料 <br><br>        <span class="bold">{lang guest}:  </span><a href="$link_register">{lang register}</a><br>        | <a href="$link_login">{lang login}</a> <br><br><!--{/if}--> --- 结束这个判断(判断1)

2. The statements xxx are often seen in templates.
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:
in header template

Copy content to clipboard
Code:
<!--{loop $plugins['links'] $plugin}--> --- Start loop 1, determine the plug-in <code id="code1"><!--{loop $plugins['links'] $plugin}--> --- 循环1开始,判断插件<br>        <!--{loop $plugin $module}--> --- 循环2开始,判断插件模组 <br>             <!--{if !$module['adminid'] || ($module['adminid'] && $adminid > 0 && $module['adminid'] >= $adminid)}-->| $module[url] <!--{/if}--> <br>        <!--{/loop}--> --- 结束循环2 <br><!--{/loop}--> --- 结束循环1 --- Loop 2 starts, determine the plug-in module
                                                                                             '] && $adminid > 0 && $module['adminid'] >= $adminid)}-->| $module[url]

< ;!--{/loop}--> --- End loop 2 --- End loop 1
4. Language call

In templates, you often see statements like {lang xxx}. It is used to call words in the language package. Most of the things that will be called in templates are templates.lang.php.

Let’s take a look at the structure of the language pack:
Copy content to clipboard<? -- 宣布php语言开始<BR>$language = array<BR>( --- 以上宣布语言包定义开始 <br><br> 'title' => '标题', <br>        调用字符    显示文字 <br>        'never' => '从未', <br>        调用字符    显示文字<br>        ....<br>); --- 宣告语言包定义结束<br>?>  -- 宣布php语言结束
Code: & lt ;?-Announce the beginning of PHP language <p> $ Language = Array <span style="COLOR: blue"> title' => 'Title', </span>                                                                                                                                                                                                                                                                                        -- Announce the end of the language package definition <br>?> -- Announce the end of the php language </p>


Related examples:

Suppose we add a language call and add
'abc' = in the line above
'title' => 'title',
> 'This is a test language call',
The last one is indispensable, as well as the calling characters and display text, which must be caused by ''. After is added, you can call it in the template. Write {lang abc} in the template and it will be displayed directly: This is the test language call


Special Note: After adding a language or modifying a language pack, the cache must be updated! 5.
Style

Parameter call is commonly seen in templates { XXXXX} statement. {} 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 and the other is replacement content


Related examples:

For variables, write FOOTERCOLOR (note that capital letters must be used)
Replace the content and write #003399After submission, modify the template and write Test style custom variableThen the effect will be, this test The 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 templates!

http://www.bkjia.com/PHPjc/320579.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/320579.html
TechArticle
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} Assume that a new template named "abc.ht...
is created
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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template