Home  >  Article  >  Backend Development  >  Empire CMS list template listvar supports program code

Empire CMS list template listvar supports program code

ringa_lee
ringa_leeOriginal
2018-05-11 15:21:133088browse

1. When adding a template, the list.var template needs to check the "Use program code" option. As shown in the picture:

2. Add PHP code directly, no need to add

list.var Template example:
Example 1: If the information does not set a title image, display the specified image.

1if(empty($r[titlepic]))
2{
3        $r[titlepic]='/images/img.gif';
4}
5 $listtemp=&#39;<li><a href="[!--titleurl--]"><img src="[!--titlepic--]">a>li>&#39;;

Explanation: $r[titlepic] is the title picture field variable. $listtemp is the template content variable.

Example 2: If the information is released today, display the "NEW" image logo.

1$newimg=&#39;&#39;;
2 if(time()-$r[newstime]<=1*24*3600)
3{
4        $newimg=&#39;<img src="NEW图片地址" border="0">&#39;;
5}
6 $listtemp=&#39;<li><a href="[!--titleurl--]">[!--title--]a> &#39;.$newimg.&#39;li>&#39;;

Explanation: $r[newstime] is the release time field variable. $listtemp is the template content variable.

Example 3: Call the company name of the submitting user.

1$userr=$empire->fetch1("select company from {$dbtbpre}enewsmemberadd where userid=&#39;$r[userid]&#39; limit 1");
2 $listtemp=&#39;<li><a href="[!--titleurl--]">[!--title--]a><span>公司名称:&#39;.$userr[company].&#39;span>li>&#39;;

Description: $r[userid] is the publisher user ID field variable. $listtemp is the template content variable.

Other instructions:
If $listtemp refers to the template content using single quotes, then the single quotes must be added in front of it, for example: $listtemp='e2bc8e0df8ee9ae5086eb844173c87fa' ;
On the contrary, if you use double quotes to quote the template content, you must also add double quotes before the double quotes, for example: $listtemp="4802e4e9fee0dce56d39093587a29fe0";
Support program The code can implement many very complex application requirements.

The above introduces the Empire CMS list template listvar support program code, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement:
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