Empire CMS list template listvar supports program code

ringa_lee
Release: 2023-03-01 06:44:01
Original
3063 people have browsed it

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;;
Copy after login

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;;
Copy after login

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;;
Copy after login

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='' ;
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="";
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.

Related labels:
gt lt
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!