Dedecms template creation and usage

Source: Internet
Author: User


Parsing 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 = <a href = 'arcurl'> title </a>
Typelink = <a href = 'typeurl'> typename </a>
Imglink = <a href = 'arcurl'> </a>
Image =

Variable call method: [field: varname/]

For example:
{Dede: arclist infolen = '000000 '}
[Field: textlink/]
<Br>
[Field: info/]
<Br>
{/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 '}
<A href = '[field: typelink/]'> [field: typename/] </a>
{/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 <table content>

7. Mark mynews

Used to obtain news from the website

Applicability: 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 tag

This 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 flag

Used to obtain the content list of lower-level columns of a channel

Applicability: Cover Template

Syntax:

{Dede: channelArtlist typeid = 0 col = 2 tablewidth = '000000 '}
<Table width = "99%" border = "0" cellpadding = "3" cellspacing = "1" bgcolor = "# BFCFA9">
<Tr>
<Td bgcolor = "# E6F2CC">
{Dede: type}
<Table border = "0" cellpadding = "0" cellspacing = "0" width = "98%">
<Tr>
<Td width = '000000' align = "center"> </td>
<Td width = '000000'>
<A href = "[field: typelink/]"> [field: typename/] </a>
</Td>
<Td width = '000000' align = 'right'>
<A href = "[field: typelink/]"> more... </a>
</Td>
</Tr>
</Table>
{/Dede: type}
</Td>
</Tr>
<Tr>
<Td height = "150" valign = "top" bgcolor = "# FFFFFF">
{Dede: arclist row = "8 "}
· <A href = "[field: arcurl/]"> [field: title/] </a> <br>
{/Dede: arclist}
</Td>
</Tr>
</Table>
<Div style = 'font-size: 2px '> </div>
{/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/] <br>
{/Dede: fieldlist}

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.