Supported program code in the CMS list template listvar

Source: Internet
Author: User
: This article mainly introduces the script code supported by the CMS list template listvar. For more information about PHP tutorials, see. 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.

1if(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.

    The preceding section describes the supported program code of the DMS list template listvar, including some content. if you are interested in the PHP Tutorial.

    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.