Discuz Template Label parsing

Source: Internet
Author: User
Tags code tag

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 resolves the nested template content to a PHP statement and merges it into the template
      <!--{Subtemplate common/header}-->
      Common/header header.html template file corresponding to the common directory in a template set

      Program runtime include nested template content
      <!--{Template common/header}--> Note: When there are more loops in the template, try to use subtemplate
    2.   Logical judgment If...else
      1. if written in an HTML form element, you can save the code from making it clearer and easier to read, such as {if $my _var}xxx{/if}
        <!--{if $_g[' uid ' ]}--> arbitrary HTML Statements <!--{/if}-->//is especially important if you are judging an attribute value of an HTML tag, preferably with <!----> comment symbol if it is outside the label   
      2. If syntax with branching conditions
        <!--{if $_g[' UID ']}--> any HTML statement <!--{ElseIf $_g[connectguest]}--> any HTML statement < !--{/if}-->
      3. with multi-conditional if notation, using the bitwise operator in PHP general judgment, such as
        <!--{if empty ($_g[' forum ' [' Picstyle ']) && $_ Get[' by '] = = ' Lastpost ' && empty ($_get[' filter ')}-->
             arbitrary HTML statements  
        <!--{/if}-->
      4. CSS can also be set by criteria when writing a setting such as:
        <td class= "Fl_g" {if $forumcolwidth} width= "$forumcolwidth" {/if}>///As stated above, When judging the attribute values in the HTML tag, you can omit the comment <!----;
    3. Execute PHP code tag directly:<!--{eval echo $my _var;} -//equivalent to <?php echo $my _var;? >
      <!--{eval $my _arr = Array (1, 2, 3);} -//equivalent to <?php $my _arr=array (a);? >
      <!--{eval print_r ($my _arr);} -//equivalent to <?php print_r ($my _arr);? >
      <!--{eval output ();} --//equivalent to <?php output ();? >
      <!--{eval exit ();} -//equivalent to <?php exit ();? >
    4. Direct output variable, equivalent to PHP <?php echo $my _var;, curly braces can be omitted but not recommended. (The module program is processed before it can be called here): <div id= "ANC" ><ul id= "Ancl" > $announcements </ul></div>// In general, the output is not a simple variable
      <!--{echo cutstr ($group [Lastpost][subject], 1)}-->//Conditions of Use: 2-variables need to be processed by the function-the output is a variable, not an array
    5. Ad embed Point code:<!--{ad/headerbanner/wp a_h}-->//This is discuz embedded ads, we recommend that you customize the ad bit, custom ad bit in the background will automatically generate the call code, we just paste copy to
    6. Plug-in hook tag:<!--{hook/global_usernav_extra2}-->
      Hook as a keyword, meaning to define index_top as a hook
    7. Cyclic syntax (multiple loops) with array keys for loop notation
      <!--{loop $my _arr $key $val}-->
      HTML statements for looping output
      <!--{/loop}-->

      Loop notation with no array keys
      <!--{loop $_g[' setting ' [' Navs '] $nav}-->
      HTML statements for looping output
      <!--{/loop}-->
    8. DIY zone and background data call tags:<!--[diy=diy1]--><div id= "diy1" class= "area" ></div><!--[/diy]-->// 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! Use of the template file after the language pack is loaded: {lang Forum_category_modedby}
      Where language packs are stored in the./source/language/directory, in the form of an array of PHP

Discuz Template Label parsing

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.