The CMS list template list. var Supports program code, cmslist. var_PHP tutorial

Source: Internet
Author: User
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...

    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.