Discuz template syntax

Source: Internet
Author: User
: This article mainly introduces the discuz template syntax. if you are interested in the PHP Tutorial, refer to it. Discuz! The parsing of the X template is mainly for./source/class/class_template.php file parsing. For more information, see this file!

    1. Template nesting syntax

      Resolve the content of the nested template into PHP statements and merge them into the writing method in this template.

      The common/header corresponds to the header.html template file in the common directory of a template.
      Include nested template content when running the program

      Note: When there are many loops in the template, use subtemplate whenever possible.
    2. Logic judgment if... else

      1. If the code is written in an HTML form element, you can avoid making the code clearer and easier to read, for example, {if $ my_var} xxx {/if}
        Arbitrary html statement // It is especially important to judge an attribute value of an html tag. if it is outside the tag, it is best to add Annotator

      2. If statement with branch conditions
        Arbitrary html statement Arbitrary html statement
      3. If statement with multiple conditions, you can use the bitwise operator in the regular PHP judgment.

        Arbitrary html statement
      4. When CSS is written, you can set the settings according to the conditions, for example:
        // As mentioned above, comments can be omitted when determining the attribute values in html tags.

    3. Directly execute the PHP code tag:

      // Equivalent
      // Equivalent
      // Equivalent
      // Equivalent
      // Equivalent

    4. Directly output variables, equivalent to PHP's The curly braces can be omitted but are not recommended to be removed. (The Module program can be called here after processing ):

        $ Announcements

      // The output content is generally not a simple variable.
      // Usage condition: 1-the variable must be processed by the function. 2-The output is a variable, not an array.

    5. Embedded point code of the advertisement:

      // This is an embedded discuz advertisement. we recommend that you customize the ad space. the custom ad space will automatically generate the call code in the background. you only need to paste and copy the code.

    6. Hook tag of the plug-in:


      Hook is a keyword that defines index_top as a hook.

    7. Loop syntax (multiple loops are allowed)

      Circular writing with array keys

      HTML statement output by loop

      Circular writing without array keys

      HTML statement output by loop

    8. DIY region and background data call labels:

      // Do not use the diy function of discuz as much as possible, because the maintenance is very large, you can directly use 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}
      The language pack is stored in the./source/language/directory as a PHP array.

The above introduces the discuz template syntax, including the content, hope to be helpful to friends interested in PHP tutorials.

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.