Dedecms template creation usage analysis engine overview template design specification code reference
Reference: arclist (artlist, likeart, hotart, imglist, imginfolist, coolart, specart) field channel mytag vote friendlink mynews loop channelartlist page list pagelist pagebreak fieldlist
I. Zhimeng template parsing engine overview before learning about the template code of DedeCms, it is very meaningful to understand the knowledge of Zhimeng template engine. The Zhimeng template engine is a template parser that uses XML namespaces. The biggest advantage of using the Zhimeng parser to parse templates is that you can easily define tag attributes, like using HTML, the template code is very intuitive and flexible. The new Zhimeng template engine can not only parse templates, but also analyze error tags in templates.
1. the code style of the Zhimeng template engine is as follows:
{Dede: Tag name attribute = 'value '/}
{Dede: Tag name attribute = 'value'} {/dede: Tag name}
{Dede: Tag name attribute = 'value'} custom style template (InnerText) {/dede: Tag name}
Tip:
For a tag in the form of {dede: Tag name attribute = 'value'} {/dede: Tag name}, in version 2.1, "{/dede}" is used to end the process,
"{/Dede: Tag name}" must be strictly used in V3; otherwise, an error will be reported.
2. the Zhimeng template engine has multiple built-in system tags that can be directly used in any scenario.
(1) The global flag indicates obtaining an external variable. in addition to the database password, it can call any configuration parameters of the system in the form:
{Dede: global name = 'variable name'} {/dede: global}
Or
{Dede: global name = 'variable name '/}
The variable name cannot contain the $ symbol. for example, the variable $ inclu_cmspath should be written as {dede: global name = 'cfg _ cmspath '/}.
(2) foreach is used to output an array in the form:
{Dede: foreach array = 'Array name'} [field: key/] [field: value/] {/dede: foreach}
(3) include introduces a file in the form:
{Dede: include file = 'File name '/}
The search paths for files are in the absolute path, include folder, CMS installation directory, and CMS Main Template directory.
3. the woven dream mark allows the function to process the obtained value in any tag, in the form:
{Dede: Tag name attribute = 'value' function = 'youfunction ("parameter 1", "parameter 2", "@ me ")'/}
@ Me indicates the value of the current tag. other parameters are determined by your function. for example:
{Dede: field name = 'pubdate' function = 'strftime ("% Y-% m-% d % H: % M: % S", "@ me ") '/}
II. DedeCms template creation specifications
The template of the DedeCms system is non-fixed. you can select the topic template when creating a new topic. the official website only provides the most basic default template, which is the template of the built-in system model, dedeCms supports custom channel models. after you define a new channel model, you need to design a new template based on the model.
1. concepts, design and use templates must understand the following concepts:
1. plate (cover) Template:
It refers to the template used by the website's main page or relatively important column. generally, it is named after javasindex_id.htm. In addition, you can also choose whether to support plate template tags for a single page or custom tag that you have defined separately. If yes, the system uses the plate template marking engine to parse the output content or generate a specific file.
2. list template:
A template for the list of all articles in a topic of a website. it is generally named after javaslist_ id.htm.
3. File template:
Indicates the template of the document view page, which is generally named after “article_id.htm.
4. Other templates:
Generally, the system includes the following templates: homepage templates, search templates, RSS, and JS compilation function templates. In addition, you can customize a template to create any file.
II. Naming. for the sake of standardization, Zhimeng officially recommends that you use a uniform method to name the template, as shown below:
1. Template storage location:
Template directory: {cmspath/templets/style name (default in English, system is the underlying template of the system, and plus is the template used by the plug-in)/specific function template file}
General Template location: "/templets/default"
2. template file naming rules:
(1)index_ id.htm: indicates the section (column cover) template;
(21_list_id.htm: indicates the topic list template;
(3)article_ id.htm: indicates the content View Page (document template, including the topic view page );
(4)search.htm: search result list template;
(5)index.htm: Homepage template;
Note:
The [identification ID] of each content channel in your system is:
For example, list_image.htm indicates that it is the default list template of the topic whose content type is image set.
III. Reference
1. arclist flag
This tag is the most commonly used tag in DedeCms. among them, hotart, coolart, likeart, artlist, imglist, imginfolist, and specart are all extended by the different attributes defined by this tag.
Purpose: obtain a list of specified documents.
Applicability: cover templates, list templates, and document templates
(1) Basic syntax:
{Dede: arclist
Typeid = ''row = ''col = ''titlelen =''
Infolen = ''imgwidth = ''imgheight = ''listtype = ''orderby = ''keyword = ''}
Custom style template (InnerText)
{/Dede: arclist}
This tag is equivalent to artlist, imglist, and imginfolist. it is exactly the same as artlist, and is different from imglist and imginfolist, which are only the default underlying templates.
(2) attribute reference:
[1] typeid = ''indicates the topic ID. you do not need to specify the topic ID in the list template or archive template. you can specify multiple columns separately in the cover template;
[2] row = ''indicates the number of returned documents. if used with col, the number of results is equal to row * col;
[3] col = ''indicates the number of columns to be displayed (single column by default );
[4] titlelen = ''indicates the title length;
[5] infolen = ''indicates the content description length;
[6] imgwidth = ''indicates the width of the thumbnail;
[7] imgheight = ''indicates the height of the thumbnail;
[8] type = ''indicates the file type. the default value or type = 'all' indicates a common document.
§ Type = 'commend' indicates the recommendation document, which is equivalent
§ Type = 'image' indicates a document that must contain a thumbnail.
[9] orderby = ''indicates the sorting method. the default value is senddate.
§ Orderby = 'Hot 'or orderby = 'click' indicates the number of clicks
§ Orderby = 'pubdate' is arranged by publishing time (that is, the time value that can be changed at the front end)
§ Orderby = 'sortrank' sort by the new sorting level of the article (use this attribute if you want to use the top article)
§ Orderby = 'id' sort by Article id
[10] keyword = ''indicates the list of documents containing the specified keyword. Separate multiple keywords ","
[11] channelid = 'number' indicates a specific channel type. built-in channels: topic (-1), article (1), Gallery (2), Flash (4), software (3)
[12] limit = 'Start, end 'indicates a limited record range. the row attribute must be equal to "end-start". mysql limit statements start from 0, for example, "limit" indicates that the first five records are obtained, and "limit" indicates that the fifth record starts and five records are removed.
(3) underlying Template variables
ID (same id), title, iscommend, color, typeid, ismake, description (same as info ),
Pubdate, senddate, arcrank, click, litpic (same as picname), typedir, typename,
Arcurl (same as filename), typeurl, stime (pubdate in the "0000-00-00" format ),
Textlink, typelink, imglink, image
Where:
Textlink = title
Typelink = typename
Imglink =
Image =
Variable call method: [field: varname/]
For example:
{Dede: arclist infolen = '000000 '}
[Field: textlink/]
[Field: info/]
{/Dede: arclist}
2. field flag
This tag is used to obtain the field values and common environment variable values of a specific column or category.
Applicability: cover templates, list templates, and document templates
(1) Basic syntax
{Dede: field name = ''/}
(2) name attribute value:
Plate Template: phpurl, indexurl, indexname, templeturl, memberurl, powerby, webname, specurl
List Template: position, title, phpurl, templeturl, memberurl, powerby, indexurl, indexname, specurl, all fields in the dede_arctype column table
The position is a link in the form of "column 1> Column 2", and the title is the title in this form.
Document Template: position, phpurl, templeturl, memberurl, powerby, indexurl, indexname, specurl, id (same ID, aid), all fields of the file dede_archives table and the additional table.
3. channel tag
Used to obtain the column list
Applicability: cover templates, list templates, and document templates
(1) Basic syntax
{Dede: channel row = ''type = ''}
Custom style template (InnerText)
{/Dede: channel}
(2) attributes
[1] row = 'number' indicates the number of records to be retrieved (generally used when there are too many columns at a certain level, the default value is 8)
[2] type = top, sun, self
Type = 'top' indicates top-level columns
Type = 'sun' indicates a subtopic
Type = 'self 'indicates the same level column
The last two attributes must be used in the list template.
(3) underlying Template variables
ID, typename, typedir, and typelink (only the URL of the topic is shown here)
Example:
{Dede: channel type = 'top '}
[Field: typename/]
{/Dede: channel}
4. mytag tag
Used to obtain the content of a custom tag
Applicability: cover templates, list templates, and document templates
(1) Basic syntax
{Dede: mytag typeid = ''name ='' ismake = ''/}
(2) attributes
[1] typeid = 'number' indicates the topic ID. the default value is 0. the tag of this name is not defined in the unspecified topic, the following search method is used to search for the "first look up the parent column-> General mark (typeid = 0) with the same name Mark ".
[2] name = ''indicates the name.
[3] ismake = yes | no by default. no indicates that the content in mytag does not contain tags of other cover templates. yes indicates that the tag content contains tags of other cover templates.
5. vote mark
Used to obtain a set of voting forms
Applicability: cover template
(1) Basic syntax
{Dede: vote id = 'voting ID' lineheight = '22'
Tablewidth = '000000' titlebgcolor = '# ede2'
Titlebackground = ''tablebgcolor = '# ffff '}
{/Dede: vote}
6. the friendlink flag is equivalent to the flink
Used to obtain links
Applicability: cover template
(1) Basic syntax
{Dede: flink type = ''row = ''col = ''titlelen = ''tablestyle = ''} {/dede: flink}
Property annotation:
[1] type: Link type, value:
A. textall is displayed in text
B. mix textimage text and graph
C. text only displays links without Logo
D. image only displays links with logos
-------------------------------------
[2] row: number of rows displayed. the default value is 4.
[3] col: number of columns displayed. the default value is 6 columns.
[4] titlelen: length of site text
[5] tablestyle: Indicates
7. Mark mynewsUsed to obtain news from the websiteApplicability: cover template(1) Basic syntax{Dede: mynews row = 'number of entries 'titlelen = 'title length'} Innertext {/dede: mynews}Innertext supports the following fields: [field: title/], [field: writer/], [field: senddate/] (time), [field: body/]8. loop tagThis interface is used to call data from any table. it is generally used to call operations such as forum posts. for details, see Forum extensions.9. channelartlist flagUsed to obtain the content list of lower-level columns of a channelApplicability: cover templateSyntax:{Dede: channelArtlist typeid = 0 col = 2 tablewidth = '000000 '}
{Dede: type}
|
[Field: typename/]
|
More...
|
{/Dede: type}
|
{Dede: arclist row = "8 "} · [Field: title/] {/Dede: arclist}
|
{/Dede: channelArtlist}
ChannelArtlist is the only tag that can directly nest other tags, but only for nesting
{Dede: type} {/dede: type} and {dede: arclist} {/dede: arclist}
Mark.
(1) attributes
Typeid = 0 channel ID. by default, the nested tag uses the subtopic of this topic ID. if you want to use a specific topic, you can use ", "Separate multiple IDs.
Col = 2 + columns
Tablewidth = '000000' size of the peripheral table
10. page tag
Additional parameters of the paging page
Applicability: list template
Syntax:
{Dede: page pagesize = "number of results per page "/}
11. list tag
List content list in the list template
Syntax:
{Dede: list col = ''titlelen =''
Infolen = ''imgwidth = ''imgheight = ''orderby = ''} {/dede: list}
Underlying Template variables
ID (same id), title, iscommend, color, typeid, ismake, description (same as info ),
Pubdate, senddate, arcrank, click, litpic (same as picname), typedir, typename,
Arcurl (same as filename), typeurl, stime (pubdate in the "0000-00-00" format ),
Textlink, typelink, imglink, image
12. pagelist flag
Indicates the page number list.
Applicability: list template
Syntax:
{Dede: pagelist listsize = "3 "/}
Listsize indicates the length of [1] [2] [3] Items x 2
13. pagebreak flag
Purpose: list the pagination links of a document.
Applicability: only document templates are supported.
Syntax: {dede: pagebreak /}
14. fieldlist flag
Purpose: obtain information about all fields in the additional table.
Applicability: only document templates are supported.
Syntax:
{Dede: fieldlist}
[Field: name/]: [field: value/]
{/Dede: fieldlist}