Imperial CMS list template List.var support program code, Cmslist.var
1, add template List.var template need to check the "Use program code" option.
2, add the PHP code directly, do not need to add program start and end tag.
3, the field value array variable is ", the corresponding field variable is $r[field name], such as: The title field variable is $r[title]. Another number variable is $no
4. Assign the final template content to the $listtemp variable.
Examples of List.var templates:
Example 1: Displays the specified picture if the message does not have a caption picture set.
1 if (Empty ($r [titlepic])) 2 {3 $r [titlepic]= '/images/img.gif '; 4 }5 $listtemp = '<Li><href = "[!--titleurl--]" >< src= "[!--titlepic--]">
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, the "NEW" Picture logo is displayed.
1 $newimg = "; 2 if (Time ()-$r [Newstime]<=1*24*3600)3{4 $newimg = 'src= ' new picture address ' border= ' 0'>'; 5 }6 $listtemp = '<Li><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><href= ' [!--titleurl--] ' >[!--title--]
a><span > name: '. $userr [Company]. '
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 = ' \ ' [!--titlepic--]\ '> ';
Conversely, if the reference template content is double quotation marks, then the inside use double quotation marks before also add \, for example: $listtemp = "\" [!--titlepic--]\ ">";
Support Program code can implement many very complex application requirements.
http://www.bkjia.com/PHPjc/1010333.html www.bkjia.com true http://www.bkjia.com/PHPjc/1010333.html techarticle Imperial CMS list template List.var support program code, Cmslist.var 1, add template when List.var template needs to tick the use program code option. 2, directly add PHP code, do not need ...