1, add template when List.var template need to check “ use program code ” options.
2, directly add PHP code, do not need add
Examples of List.var templates:
Example 1: Displays the specified picture if the message does not have a caption picture set.
1if (Empty ($r [titlepic])) 2{3 $r [titlepic]= '/images/img.gif '; 4}5 $listtemp = ' <li><a href= ' [!-- titleurl--] ">a>li>";
Description: $r [Titlepic] is the title picture field variable. $listtemp as a template content variable.
Example 2: If the information is released today on the display “ new” picture identification.
1$newimg= '; 2 if (Time ()-$r [newstime]<=1*24*3600) 3{4 $newimg = ' '; 5}6 $ listtemp= ' <li><a href= "[!--titleurl--]" >[!--title--]a> '. $newimg. ' Li> ';
Description: $r [Newstime] is the Publish Time field variable. $listtemp as a template content variable.
Example 3: Call the company name of the contributing user.
1$userr= $empire->fetch1 ("select company from {$dbtbpre}enewsmemberadd where userid= ' $r [userid] ' limit 1"); 2 $ listtemp= ' <li><a href= "[!--titleurl--]" >[!--title--]a><span> Company name: '. $userr [companies]. ' Span>li> ';
Description: $r [UserID] is the Publisher User ID field variable. $listtemp as a template content variable.
Other Notes:
If the $listtemp reference template content is in single quotation marks, then the inside use single quotation marks in front to add \, for example: $listtemp = ' ';
Conversely, if the reference template content is double quotation marks, then the inside use double quotation marks before also add \, for example: $listtemp = "Support Program code can implement many very complex application requirements.
The above describes the Imperial CMS list template Listvar support program code, including the aspects of the content, I hope to be interested in PHP tutorial friends helpful.