The CMS list template list. var Supports program code, cmslist. var. The CMS list template list. var Supports program code. cmslist. var1. when adding a template list. var template, you must select the use program code option. 2. directly add the PHP code. you do not need the dpc cms list template list. var to support the program code, cmslist. var
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.
1 if(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.
List template list. var Supports program code. cmslist. var 1. when adding a template list. var template, you need to check the use program code option. 2. directly add the PHP code, no need...