: This article mainly introduces the script code supported by the CMS list template listvar. For more information about PHP tutorials, see. 1. when adding a template, select the "use program code" option for the list. var template.
2. directly add PHP code without adding Program start and end tags.
3. The field value array variable is $ r, and the corresponding field variable is $ r [field name]. for example, the title field variable is $ r [title]. The variable number is $ no.
4. assign the final Template content to the $ listtemp variable.
List. var template example:
Example 1: If the title image is not set, the specified image is displayed.
1if(empty($r[titlepic]))2{3 $r[titlepic]='/images/img.gif';4}5 $listtemp='
';
Note: $ r [titlepic] is the title image field variable. $ Listtemp is the template content variable.
Example 2: If the message is published today, the "NEW" image ID is displayed.
1 $ newimg = ''; 2 if (time ()-$ r [newstime] <= 1x24x3600) 3 {4 $ newimg = 'src = "NEW image address" border = "0"> '; 5} 6 $ listtemp ='
[! -- Title --] '. $ newimg .'';
Note: $ r [newstime] is the release time field variable. $ Listtemp is the template content variable.
Example 3: Call the company name of the contributor.
1 $ userr = $ empire-> fettings ("select company from {$ dbtbpre} enewsmemberadd where userid = '$ r [userid] 'limit 1"); 2 $ listtemp ='
[! -- Title --]Company name: '. $ userr [company].'';
Description: $ r [userid] is the publisher's user ID field variable. $ Listtemp is the template content variable.
Other instructions:
If the content of the $ listtemp reference template is in single quotes, add \ before the single quotes. for example: $ listtemp = '\'[! -- Titlepic --] \ '> ';
On the contrary, if the content of the referenced template uses double quotation marks, add \ before the double quotation marks, for example, $ listtemp = "\"[! -- Titlepic --] \ "> ";
Supporting program code can meet many very complex application requirements.
The preceding section describes the supported program code of the DMS list template listvar, including some content. if you are interested in the PHP Tutorial.