Dedecms template Production using method _php example

Source: Internet
Author: User
Tags new set tag name 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

The Dream template parsing engine overview Before you know Dedecms's template code, it makes sense to understand the knowledge of a dream template engine. Dream-Weaving template engine is a template parser using the XML namespace form, the biggest benefit of parsing a template with a dream parser is that it makes it easy to make the attributes of the tag, feeling like you're using HTML, making the template code very intuitive and flexible, The new version of the Dream template engine can not only implement the template parsing can also be analyzed in the template error tags.

1, Dream template Engine code style has the following several 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}

Tips:
For {dede: Tag name attribute = ' value '}{/dede: Tag name} This form of markup, in version 2.1, indicates end only needs to use ' {/dede} ', but
"{/dede: Tag name}" is strictly required in V3, otherwise an error will be made.

2. The Dream template engine has multiple system tags built into it, which can be used directly on any occasion.

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

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

(2) A 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 '/}
Search paths for files are in order: Absolute path, include folder, CMS installation directory, CMS master template directory

3. Dream Mark allows a function to be used in any tag to process the resulting value in the form of:
{dede: Tag name attribute = ' value ' function= ' youfunction (parameter one, parameter two, @me) '/}
Where @me is used to represent the value of the current tag, and other parameters are determined by your function, such as:
{Dede:field name= ' pubdate ' function= ' strftime ('%y-%m-%d%h:%m:%s ', ' @me ') '/}

Second, Dedecms template production specifications

The template for the DEDECMS system is not fixed, the user can choose the column template when the new column, the official only provides the most basic default template, namely is the built-in system model each template, DEDECMS supports the custom channel model, after the user customizes the new channel model, needs to design a new set of templates according to the model.
concept, design and use of templates, you must understand the following concepts:
1, plate (cover) Template:
Refers to the website homepage or the more important column cover use template, generally uses "index_ recognition id.htm" The name, moreover, the user individual definition individual page or the custom mark, also may elect whether supports the plate template marking, if supports, The system uses the plate template tag engine to parse before outputting the content or generating a specific file.
2. List template:
A template that refers to the list of all articles in a section of a Web site, usually named "List_ recognition id.htm".
3, File Template:
Represents a template for document viewing pages, typically named "Article_ recognition id.htm."
4, other templates:
General system general includes templates include: Home page template, search template, rss, JS compile function template, in addition, users can also customize a template to create arbitrary files.
Second, the name, for the sake of the norm, the dream of the official proposed to use a uniform way to name the template, specifically as follows:
1, the template save location:
Template directory: {cmspath/templets/style name (in English, default defaults, where system is the underlying template, plus the template used for Plug-ins)/specific feature template file}
Generic template location: "/templets/default"
2, template file naming norms:
(1) index_ recognition id.htm: The plate (column cover) template;
(2) List_ recognition id.htm: the column list template;
(3) Article_ recognition id.htm: Content View page (document template, including feature view page);
(4) Search.htm: Search results list template;
(5) Index.htm: homepage template;
Annotations:
Your system's [identification ID] for each content channel is:
Example: List_image.htm is a column default list template with a content type that is a picture set.

Third, the main marking reference

1, Arclist Mark

This tag is the most commonly used tag of dedecms, where Hotart, Coolart, Likeart, Artlist, Imglist, Imginfolist, Specart are all extensions of the different attributes defined by this tag.

Function: Gets a list of specified documents

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

(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 the artlist, imglist, imginfolist tag, which is exactly equivalent to artlist, unlike the Imglist, Imginfolist is only the default underlying template.


(2) attribute reference:

[1] typeid= ' represents the column ID, in the list template and file template generally do not need to specify, in the cover template allows "," separate multiple columns;
[2] row= ' Returns the number of lines in the document, if combined with Col, the number of results is equal to row * COL;
[3] col= ' represents the number of columns displayed (default is a single column);
[4] titlelen= ' denotes the length of the title;
[5] infolen= ' represents the length of the description;
[6] imgwidth= ' represents the thumbnail width;
[7] imgheight= ' represents the thumbnail height;
[8] type= ' represents the file type, where the default value or type= ' all ' is the normal document
§type= ' commend ', indicating the recommended document, is equivalent to
§type= ' Image ' indicates a document that must contain an abbreviated picture
[9] orderby= ' means sort by the default value is senddate by publication time.
§orderby= ' hot ' or orderby= ' click ' to arrange by number of clicks
§orderby= ' pubdate ' by publication time (that is, the time value that the foreground allows to change)
§orderby= ' Sortrank ' sorted by the new sorting level of the article (use this attribute if you want to use a sticky article)
§orderby= ' id ' sorted by article ID
[A] keyword= ' represents a list of documents with a specified keyword, with multiple keywords separated by ","
[One] channelid= ' digital ' indicates a specific channel type, built-in channels: Special topics (-1), Articles (1), Atlas (2), Flash (4), software (3)
[A] limit= ' Start, End ' indicates a limited range of records, the row attribute must be equal to "end-start", and the MySQL limit statement is initiated by 0, as "limit 0,5" indicates the Wubi record, "Limit 5,5" is recorded from the fifth, Remove Wubi Records.

(3) Underlying template variables

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

which
Textlink = <a href= ' Arcurl ' >title</a>
Typelink = <a href= ' Typeurl ' >typename</a>
Imglink = <a href= ' arcurl ' ></a>
Image =

Variable invocation method: [Field:varname/]

Such as:
{dede:arclist infolen= ' 100 '}
[Field:textlink/]
<br>
[Field:info/]
<br>
{/dede:arclist}

2. Field Mark

This tag is used to get the field values and commonly used environment variable values for a particular column or file eucalyptus.

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 in the column table Dede_arctype
Among them position is "column one > column two" Such form of link, title is this form of title

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


3, channel Mark

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 template (innertext)
{/dede:channel}

(2) Property

[1] row= ' number ' indicates the number of bars to get records (Universal is used when there are too many columns, default is 8)

[2] type = Top,sun,self

Type= ' Top ' represents the top-level column
Type= ' Sun ' indicates subordinate columns
Type= ' self ' indicates a similar column

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

(3) Underlying template variables

Id,typename,typedir,typelink (here is only the site of the column)

Cases:
{dede:channel type= ' top '}
<a href= ' [field:typelink/] ' >[field:typename/]</a>
{/dede:channel}

4, MyTag Mark

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) Property

[1] typeid = ' Number ' indicates the column ID, default is 0, there is not a set in the column does not define the name of the tag, will search the following way to search "first look up the parent column-> Universal tag (typeid=0) of the same name tag."

[2] name = ' ' tag name.

[3] Ismake = yes|no defaults to no means that content in MyTag does not contain tags for other cover page templates, 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= ' voting id ' lineheight= ' 22 '
Tablewidth= ' 100% ' titlebgcolor= ' #EDEDE2 '
titlebackground= ' tablebgcolor= ' ' #FFFFFF '}
{/dede:vote}


6, Friendlink mark, equal to Flink

To get Links

Scope of application: Cover template

(1) Basic grammar

{dede:flink type= ' row= ' col= ' titlelen= ' tablestyle= '} {/dede:flink}
attribute annotation:
[1]type: Link Type, Value:
A. Textall all in text display
B. Textimage text and graphics mixed arrangement
C. Text only shows links with no logos
D. Image only show links with logos
-------------------------------------
[2]row: Show how many rows, default to 4 lines
[3]col: Show how many columns, default to 6 columns
[4]titlelen: Length of site text
[5]tablestyle: <table the content here >

7, Mynews Mark

For getting news in the station

Scope of application: Cover template

(1) Basic grammar

{dede:mynews row= ' number ' titlelen= ' title length '} Innertext{/dede:mynews}

InnerText supported fields: [Field:title/],[field:writer/],[field:senddate/] (time), [Field:body/]

8. Loop Mark

Used to call any table of data, generally used to invoke the forum posts and other operations, see the Forum extension.

9, Channelartlist Mark

List of contents used to get the lower section of the channel

Scope of application: Cover template

Grammar:

{dede:channelartlist typeid=0 col=2 tablewidth= ' 100% '}
<table width= "99%" border= "0" cellpadding= "3" cellspacing= "1" bgcolor= "#BFCFA9" >
<tr>
&LT;TD bgcolor= "#E6F2CC" >
{Dede:type}
<table border= "0" cellpadding= "0" cellspacing= "0" width= "98%" >
<tr>
&LT;TD width= ' 10% ' align= ' center ' ></td>
&LT;TD width= ' 60% ' >
<a href= "[Field:typelink/]" >[field:typename/]</a>
</td>
&LT;TD width= ' 30% ' align= ' right ' >
<a href= "[Field:typelink/]" > More ...</a>
</td>
</tr>
</table>
{/dede:type}
</td>
</tr>
<tr>
&LT;TD height= "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 is limited to nesting

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

Mark.

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

col=2 multiple column display

Size of tablewidth= ' 100% ' perimeter table


10, page Mark

An additional parameter that represents a paginated page

Scope of application: list template

Grammar:

{dede:page pagesize= per page results bar/}

11. List Mark

Represents a list of contents in a list template

Grammar:

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

Underlying template variable

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

12, PageList Mark

Represents a list of paged page numbers

Scope of application: list template

Grammar:

{dede:pagelist listsize= "3"/}

Listsize represents [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: Obtain all field information for the attached table.
Scope of application: Document templates only.
Grammar:
{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.