Discuz template Syntax

Source: Internet
Author: User
discuz! The parsing of the X-template is mainly the./source/class/class_template.php file parsing process, if you need further information please take a look at this file!

    1. Template nesting syntax

      To parse the nested template content into a PHP statement and merge it into this template

      Common/header header.html template file corresponding to the common directory in a template set
      Program runtime include nested template content

      Note: When there are more loops in the template, try to use subtemplate
    2. Logic if...else

      1. If you write in an HTML form element, you can avoid making the code clearer and easier to read, such as {if $my _var}xxx{/if}
        !--{if $ _g[' UID ']}--> arbitrary HTML statement!--{/if}-->//is especially important if you are judging an attribute value of an HTML tag, preferably in addition to the!----> comment symbol

      2. if notation with branching conditions
        !--{if $_g[' UID ']}--> any HTML statement,!--{elseif $_g[connectguest]}--> any HTML statement!--{/if}-->
      3. with multi-conditional if notation, such as
        !--{if empty ($_g[' forum '] [' Picstyle ']), using the bitwise operator in PHP general judgment && $_get[' ORDER BY '] = = ' LASTP Ost ' && empty ($_get[' filter ')}-->
        arbitrary HTML statements
        !--{/if}-->
      4. CSS can also be set by criteria when writing a setting such as:
        ///As stated above, you can omit the comment when judging the value of the attribute in the HTML tag "!----"

    3. Execute the PHP code tag directly:

      Equivalent
      Equivalent
      Equivalent
      Equivalent
      Equivalent

    4. Direct output variables, equivalent to PHP , curly braces can be omitted but not recommended to remove. (The module program is processed before it can be called here):

        $announcements
      //Normally output is not a simple variable
      Conditions of Use: 1-the variable needs to be processed by the function 2-the output is a variable, not an array

    5. Embed point code for ads:

      This is discuz embedded ads, we recommend that you customize the ad bit, the custom ad bit in the background will automatically generate the call code, we just paste copy to

    6. Plug-in Hook tags:


      Hook as a keyword, meaning to define index_top as a hook

    7. Looping syntax (multiple loops possible)

      Loop notation with array keys

      HTML statements for looping output

      Loop notation with no array keys

      HTML statements for looping output

    8. DIY zone and background data call Tags:

      Try to avoid the use of Discuz DIY features, because maintenance people are very large, can directly through the background custom module or module code
      {Block XXX}(data call module)

    9. discuz! After the language pack is loaded, use in the template file:

      {lang Forum_category_modedby}
      Where language packs are stored in the./source/language/directory, in the form of an array of PHP

The above describes the Discuz template syntax, including the aspects of the content, I hope that the PHP tutorial interested in a friend helpful.

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