Dedecms template making use _php tutorial

Source: Internet
Author: User
Tags new set wubi
Parsing engine Overview Template Design specification code reference
Tag reference: Arclist (artlist,likeart,hotart,imglist,imginfolist,coolart,specart) field channel MyTag vote Friendlink Mynews Loop channelartlist Page List pagelist pagebreak fieldlist

First, the Weaving Dream Template Parsing engine overview Before you know the template code for DEDECMS, it makes sense to know the knowledge of the dream templating engine. Weaving dream template engine is a template parser using XML namespace form, the biggest advantage of using the Dream Parser parsing template is that it can easily make the attributes of the tag, it feels like HTML, so that the template code is very intuitive and flexible, The new version of the Weaving Dream template engine not only enables the parsing of templates but also analyzes the errors in the template.

1, Weaving Dream template Engine Code style has the following forms:
{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}

For {dede: Tag name attribute = ' value '}{/dede: Tag name} This form of markup, in version 2.1, indicates that the end requires only "{/dede}", but
V3 need to strictly use "{/dede: Tag name}", otherwise it will be an error.

2, weaving Dream template engine built-in multiple system tags, these system markings can be used in any situation directly.

(1) Global tag, which means to get an external variable, in addition to the database password, can invoke any configuration parameters of the system, in the form of:
{dede:global name= ' variable name '} {/dede:global}
{dede:global name= ' variable name '/}

Where variable names cannot be added to the $ symbol, such as variables $cfg _cmspath, should be written as {Dede:global name= ' Cfg_cmspath '/}.

(2) foreach is used to output an array in the form of:
{dede:foreach array= ' array name '} [field:key/] [field:value/] {/dede:foreach}

(3) include introduces a file in the form of:
{dede:include file= ' file name '/}
The search path to the file is in order: Absolute path, include folder, CMS installation directory, CMS master template directory

3. The dream tag allows a function to be used in any tag to process the resulting value, in the form:
{dede: Tag name attribute = ' value ' function= ' youfunction ("parameter One", "parameter Two", "@me") '/}
Where @me is used to represent the value of the current tag, other parameters are determined by your function for existence, for example:
{Dede:field name= ' pubdate ' function= ' strftime ("%y-%m-%d%h:%m:%s", "@me") '/}

Second, Dedecms template production specifications

DEDECMS system template is non-fixed, users can create a new column can choose their own column template, the official only provide the most basic default template, that is, the built-in system model of the various templates, DEDECMS support the custom channel model, after the user to customize the new channel model, you need to design a new set of templates according to the model.
First, the concept, design and use of templates, must understand the following several concepts:
1, plate (cover) Template:
Refers to the website homepage or the more important section cover use template, generally uses "Index_ recognizes id.htm" The name, moreover, the user individual definition individual page or the custom mark, also may choose whether supports the plate template mark, if supports, The system will use the plate template tag engine to parse and then output the content or generate a specific file.
2. List template:
A template that refers to the list of all articles in a section of a website, usually named "List_ recognition id.htm".
3. File Template:
A template that represents a document viewing page, typically named "Article_ recognition id.htm".
4. Other templates:
General system general includes templates include: Homepage template, search template, rss, JS compile function template, etc., in addition, users can also customize a template to create any file.
Second, naming, for the sake of standardization, weaving dream official recommended to use a unified way to name the template, as follows:
1. Template Save Location:
Template directory: {cmspath/templets/style name (default, the system is the underlying template, plus the template used by the plugin)/specific feature template file}
General template location: "/templets/default"
2. template file naming specification:
(1) index_ identification id.htm: Represents the plate (column cover) template;
(2) List_ recognition id.htm: Indicates the column list template;
(3) Article_ recognition id.htm: Indicates content viewing page (document template, including thematic view page);
(4) Search.htm: Search result list template;
(5) Index.htm: homepage template;
Your system's [identification ID] for each content channel is:
Example: list_image.htm is the default list template for a column of content type picture set.

Third, the main marker reference

1. Arclist Mark

This tag is the most commonly used marker for dedecms, where Hotart, Coolart, Likeart, Artlist, Imglist, Imginfolist, and Specart are all extended by the different attributes defined by the tag.

Function: Gets a list of specified documents

Scope of application: Cover page template, list template, document template

(1) Basic syntax:

Typeid= ' row= ' col= ' titlelen= '
infolen= ' imgwidth= ' imgheight= ' listtype= ' orderby= ' keyword= '}

Custom style templates (InnerText)


This tag is equivalent to the artlist, imglist, imginfolist tags, which are exactly the same as artlist, unlike Imglist and Imginfolist, which are only the default underlying templates.

(2) attribute reference:

[1] typeid= "indicates the column ID, in the list template and profile template generally do not need to specify, in the cover template allows", "separate representation of multiple columns;
[2] row= "indicates the number of rows returned to the document, if combined with COL, the result number is equal to row * COL;
[3] col= ' indicates how many columns are displayed (default is single column);
[4] titlelen= ' indicates the title length;
[5] infolen= "indicates the length of the content introduction;
[6] imgwidth= "indicates the width of the thumbnail image;
[7] imgheight= "indicates the height of the thumbnail image;
[8] type= "indicates the file type, where the default value or type= ' all ' is a normal document
§type= ' commend ' indicates the recommended document, equivalent to
§type= ' Image ' indicates a document that must contain a thumbnail image
[9] orderby= ' indicates the Sort method, the default value is senddate by release time.
§orderby= ' hot ' or orderby= ' click ' means by number of clicks
§orderby= ' pubdate ' by publication time (that is, the time value that the foreground allows to change)
§orderby= ' Sortrank ' is sorted by the new sort level of the article (use this property if you want to use a pinned article)
§orderby= ' id ' sorted by article ID
[keyword=] Indicates a list of documents with the specified keywords, with multiple keywords separated by ","
[One] channelid= ' number ' denotes a specific channel type, built-in channel: Special (-1), article (1), Atlas (2), Flash (4), software (3)
[[] limit= ' Start, End ' indicates a limited range of records, the row property must be equal to "end-start", MySQL limit statement is starting from 0, such as "limit 0,5" is to take the previous Wubi record, "limit 5,5" means the fifth record, Remove the Wubi record.

(3) Underlying template variable

ID (same ID), title,iscommend,color,typeid,ismake,description (same as info),
Pubdate,senddate,arcrank,click,litpic (with Picname), Typedir,typename,
Arcurl (same as filename), Typeurl,stime (pubdate "0000-00-00" format),

Textlink = Title
Typelink = TypeName
Imglink =
Image =

Variable invocation method: [Field:varname/]

Such as:
{dede:arclist infolen= ' 100 '}



2. Field Mark

This tag is used to obtain the field value of a particular column or file and the values of the environment variables used.

Scope of application: Cover page template, list template, document template

(1) Basic grammar

{Dede:field name= '/}

(2) The value of the Name property:

Plate Template: Phpurl,indexurl,indexname,templeturl,memberurl,powerby,webname,specurl

List template: Position,title,phpurl,templeturl,memberurl,powerby,indexurl,indexname,specurl, all fields of column table Dede_arctype
Which position for "column one > column two" such a form of link, title is the title of this form

Document Template: Position,phpurl,templeturl,memberurl,powerby,indexurl,indexname,specurl,id (with Id,aid), archive Dede_ Archives all fields of the table and attached tables.

3. Channel marking

Used to get a list of columns

Scope of application: Cover page template, list template, document template

(1) Basic grammar
{dede:channel row= ' type= '}
Custom style templates (InnerText)

(2) Properties

[1] row= ' number ' indicates the number of entries to get the record (common use when there are too many columns in a certain level, default is 8)

[2] type = Top,sun,self

Type= ' top ' denotes top column
Type= ' Sun ' indicates a subordinate column
Type= ' self ' indicates a peer column

The latter two properties must be used in the list template.

(3) Underlying template variable

Id,typename,typedir,typelink (this is only the URL of the column)

{dede:channel type= ' top '}

4. MyTag Mark

Used to get the contents of a custom tag

Scope of application: Cover page template, list template, document template

(1) Basic grammar

{dede:mytag typeid= ' name= ' ismake= '/}

(2) Properties

[1] typeid = ' Number ' indicates the column ID, the default is 0, in the column does not have a definition of the name of the tag, the search method as follows to search for "first up to find the parent column, universal tag (typeid=0) The same name tag".

[2] name = ' Tag '.

[3] Ismake = yes|no default to no means that the contents of MyTag do not contain other cover page template tags, yes indicates that the tag content contains other cover page template tags.

5. Vote Mark

Used to get a set of voting forms

Scope of application: Cover template

(1) Basic grammar
{dede:vote id= ' poll id ' lineheight= ' 22 '
Tablewidth= ' 100% ' titlebgcolor= ' #EDEDE2 '
Titlebackground= ' tablebgcolor= ' #FFFFFF '}

6, Friendlink mark, equivalent to Flink

Used to get links

Scope of application: Cover template

(1) Basic grammar

{dede:flink type= ' row= ' col= ' titlelen= ' tablestyle= '} {/dede:flink}
Attribute annotations:
[1]type: Link Type, Value:
A. Textall all in text display
B. textimage text and graphs mixed arrangement
C. Text only shows links without logos
D. Image only displays links with logos
[2]row: Shows how many rows, default to 4 rows
[3]col: Shows how many columns, default to 6 columns
[4]titlelen: Length of site text
[5]tablestyle: Indicates

7. Mynews tag is used to obtain the site news application scope: Cover template (1) Basic syntax {dede:mynews row= ' number ' titlelen= ' title length '}innertext{/dede:mynews} Innertext supported fields: [ Field:title/],[field:writer/],[field:senddate/] (time), [field:body/] 8, the loop tag is used to invoke data from any table and is generally used to invoke actions such as forum postings, see the Forum extension. 9. Channelartlist tag to get the content list for the sub-column of the channel: cover template syntax: {dede:channelartlist typeid=0 col=2 tablewidth= ' 100% '}





{dede:arclist row= "8"}
· [Field:title/]



Channelartlist is the only tag that can nest other tags directly, but is limited to nesting

{Dede:type} {/dede:type} and {dede:arclist}{/dede:arclist}


(1) Properties
Typeid=0 Channel ID, by default, nested tags use the column ID of the sub-column, if you want to use a specific column, you can use "," separate multiple IDs.

col=2 Display of multiple columns

Tablewidth= ' 100% ' Peripheral table size

10. Page Tag

Additional parameters that represent the paging page

Scope of application: list template


{dede:page pagesize= "number of result bars per page"/}

11. List tag

Represents a list of content in a list template


{dede:list col= ' titlelen= '
infolen= ' imgwidth= ' imgheight= ' orderby= '}{/dede:list}

Underlying template variable

ID (same ID), title,iscommend,color,typeid,ismake,description (same as info),
Pubdate,senddate,arcrank,click,litpic (with Picname), Typedir,typename,
Arcurl (same as filename), Typeurl,stime (pubdate "0000-00-00" format),

12. PageList Mark

Represents a paginated page number list

Scope of application: list template


{dede:pagelist listsize= "3"/}

Listsize = [1][2][3] The length of these items x 2

13. PageBreak Mark

Purpose: Represents a list of pagination links for a document.
Scope of application: Document templates only.
Syntax: {dede:pagebreak/}

14. FieldList Mark
Purpose: Gets all the field information for the attached table.
Scope of application: Document templates only.
[Field:name/]: [Field:value/]

{/dede:fieldlist} true techarticle parsing engine Overview Template Design specification code reference Tag reference: Arclist (Artlist,likeart,hotart,imglist,imginfolist,coolart,specart) Fieldchannelmytagvotefriendlinkmynewsloopchanne ...

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