Imperial CMS list template List.var support program code, cmslist.var_php tutorial

Source: Internet
Author: User

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 ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.