Destoon official tag Daquan _ PHP Tutorial

Source: Internet
Author: User
Destoon official tags. What is Label call? Tag calling reads the number of pagesize data records from the table according to the condition of the call, sorts the data by order, and finally uses the label mode What is Label call?

Tag calling reads the number of pagesize data records from the table based on the condition of the call, and sorts the data by order, finally, data is output through the layout of the tag template.
It can be seen that the tag operation is divided into two parts: reading data and displaying data.
Tag function prototype

The tag function is stored in include/tag. func. php.
Tag ($ parameter, $ expires = 0)
$ Parameter indicates the string passed to the tag function. The system automatically converts the string to multiple variables.
For example, pass table = destoon & pagesize = 10 & hello = world
The system is equivalent
$ Table = 'deston ';
$ Pagesize = 10;
$ Hello = 'world ';
Three variables
$ Expires indicates the tag cache expiration time> 0 cache $ expires seconds; 0-default tag cache time;-1-no cache;-2-cache SQL results;
In general, it is left empty by default.


Data reading process

For example, the following labels:

 

Is converted to the following SQL statement:

SELECT *FROM destoon_sellWHERE status=3ORDER BY addtime DESCLIMIT 0,10

The read data is saved in the $ tags array.
Data Display process

1. display by tag Template
Pass & template = abc to the tag function, for example:

 

The default tag template is saved in the template directory/tag/Directory. for example, & template = abc will call the template directory/tag/abc.htm template to display data.
If the tag template is stored in another directory, for example, def, & dir = def & template = abc is passed. the system calls the template directory/def/abc.htm template.

2. loop data directly in the template

 


In this way, the tag template is null and data is directly returned to the $ tags array. in this case, you can loop through the template directly.
The following is a complete example:

 {loop $tags $t}…{/loop>

The first method is generally used for data that is called multiple times, and the second method is generally used for data that is called only once.
Common parameters and definitions

Moduleid
Moduleid refers to the module ID, which can be queried in the background module management. After you set the correct Module ID for directly calling the module data, you do not need to pass the table parameter. The system automatically obtains the data.
For example, if moduleid = 5 is passed, the system will identify it as calling the supply information and automatically set the table parameter to dynamic

Table
Table refers to the table name, which can be queried in the background database maintenance. For a Destoon system table, you do not need to add the table prefix. for a non-Destoon system table, you must enter the complete table name and pass the prefix parameter.
For example, for a Destoon system table, pass table = partition. if the table prefix is destoon _, the system recognizes the table name destoon_partition.
For non-Destoon system tables, pass table = tb_abc & prefix = or table = abc & prefix = tb _. The system recognizes the table name tb_abc.

Fields
Fields indicates the query field. the default value is *. It can be passed, for example, fields = title, addtime, but generally does not need to be passed. the tag cache mechanism unique to Destoon automatically caches the query results without worrying about efficiency issues.

Condition
Condition refers to the query condition. if it is not passed, it is 1, which indicates the data of any condition (this item requires understanding of the SQL syntax ). All Destoon modules follow the unified standard development, so many conditions are common.
For example, status = 3 indicates the information that passes normally, status = 3 and level = 1 indicates the information of level 1, status = 3 and thumb <> "indicates the information of the title image.

Order
Order Index data sorting method (this item requires an understanding of the SQL syntax ).
For example, order = addtime desc indicates sort by add time in descending order, order = itemid desc indicates sort by itemid in descending order, and order = rand () indicates random data.

Pagesize
Pagesize indicates the number of data calls. if not passed, the default value is 10.

Template
Template refers to the specified tag template. if it is not passed, the default value is list, which is located in the template directory/tag/list.htm. if it is passed as null, the tag template is not applied. See the preceding data display process.
Examples of other common usage

Multi-table joint query
For example, to query the members and company information of a member named destoon, you can use:

{tag(“table=destoon_member m,destoon_company c&prefix=”&condition=m.userid=c.userid and m.username='destoon'&template=list-com”)}

Destoon_member and destoon_company are the actual names (including the table prefix) of the table. prefix = "indicates that the system does not automatically prefix the table name.

Control Title length
Transfer the length parameter in the tag. for example, & length = 20 indicates the length of 20 characters (one Chinese character occupies 2 characters). We recommend that you use css to hide extra characters (define the height and overflow: hidden)
The length parameter is passed. The system only automatically intercepts the title field. to intercept other fields, use the dsubstr function.
For example, {dsubstr ($ t [company], 20 ,'... ')} Indicates to intercept the company field with 20 characters. After intercept, append it to the end...

Set date display format
You can pass the datetype parameter in the tag:
1 indicates the year;
2 indicates the month-day;
3 Indicates year-month-day;
4 indicates the month-day hour: minute;
5 Indicates year-month-day hour: minute;
6 Indicates year-month-day hour: minute: Second
You can also directly use the date function in the template. for example, {date ('Y-m-D', $ t [addtime])} indicates converting the time to the year-month-day format.

Call the information of a certain category
Pass the catid parameter in the tag. for example, & catid = 5 indicates that all information with Category ID 5 is called.
If multiple categories are called, use commas (,) to separate the category ids. for example, & catid = 5, 6, and 7 indicate all the information of the called category IDs of 5, 6, and 7.
By default, a category call contains sub-categories. if you do not need to include sub-categories, you can set the & child = 0 parameter.
For example, & catid = 5 & child = 0 indicates that only the information with the category ID 5 is called, excluding the information of the subcategory.

Call the information of a region
The called Region information is exactly the same as the method used to call the classification information. replace the catid with areaid.

Category of the displayed information

{$CATEGORY[$t[catid]][catname]}

Control columns
This item is commonly used for image layout. you can use the cols parameter.
For example, if you call 12 images and display 4 images in one row and 3 rows in total, Pass & pagesize = 12 & cols = 4
Label Templates supporting colsparts are limited to thumb-table.htmand list-table.htm
Among them, thumb-table.htmdisplays the image watermark and list-table.htm displays the text list.
If you create a new label template that supports cols or directly cycle $ tags, refer to the preceding two templates.
The preceding results can also be implemented through CSS. you do not need to use tables. please write them by yourself.

Show article introduction
Use the {$ t [introduce]} variable. to intercept characters such as 80 characters, use {dsubstr ($ t [introduce], 80 ,'... ')}

Function prototype
Tag ($ parameter, $ expires = 0)
$ Parameter indicates the string passed to the tag function. The system automatically converts the string to multiple variables.
For example, if you pass table = destoon & pagesize = 10, the system returns $ table = 'deston'; $ pagesize = 10; two variables.
$ Expires indicates the cache expiration time
> 0 cache $ expires seconds; 0-default system time;-1-no cache;-2-cache SQL; generally, keep the default value.

Constant
{DT_SKIN}
System style url.
{DT_PATH}
Website homepage url.

Variable
$ Tags
Save the data called by the tag as an array. you can use the loop syntax to traverse and display the data.
$ Pages
The data paging code is only valid when paging is called.
$ MODULE [5] [name]
The name of the module whose ID is 5.
$ MODULE [5] [linkurl]
Module URL with ID 5.
$ CATEGORY [5] [catname]
The CATEGORY name with ID 5 (valid only when the variable $ CATEGORY exists ).
$ CATEGORY [5] [linkurl]
Category url with ID 5 (valid only when the variable $ CATEGORY exists ).

Common Fields
Title; linkurl link; catid Category ID; introduce introduction; addtime addition time; common functions dsubstr ($ string, $ length, $ suffix = ")
Truncate the string $ string to $ length, and append $ suffix (for example,...) to the end ..)
Date ($ format, $ timestamp)
Convert the timestamp $ timestamp to $ format (for example, Y-m-d ).

Tag Template
The template is saved in the./template/default/tag/directory;
We recommend that you do not delete or modify your own template. we recommend that you create and apply the template based on your own template.

1. brief description of tag format

 

Moduleid = 9 is the Information Module ID, which can be viewed by module management;
Article is the directory name of the information module;
& Amp; length = 40 indicates the number of words intercepted by the tag.
& Amp; pagesize = 10 indicates the number of calls.
& Amp; datetype = 2: display the time added

2. call the latest join Enterprise

 4&pagesize=10&order=userid desc&template=list-com”)}–>

3. how to call the supply and demand information and information of an enterprise member
Add and username = 'XXX' in condition = '? Xxx is the member login name

4. how to call a category under supply and purchase products
You can set & catid = industry id & child = 1 child = 1 to call the subordinate industry at the same time.

5. call the list of second-level columns

 

You can use the code $ catid to change the topic id you want to call in the article module.
If you need to call the column information at the same time, child = 1; otherwise child = 0
If it is called elsewhere on the website, you can use the following code:

 

Note that the value of moduleid must be consistent with the module id you call.
Supplement:
The following message is successfully called on the homepage.

 

However, I want the template list on the information page, that is, each of which only displays 22 characters.

6. how to call the Homepage information
"9" is your Module ID

{php $C = get_maincat(0, cache_read(‘category-9.php'));}{loop $C $k $v}{$v[catname]}{/loop}


7. words cannot be controlled in the company list !!
You can modify list-com.htm directly
{$ T [company]} is {dsubstr ($ t [company], $ length )}

8. common TAG
{$ CATEGORY [$ t [catid] ["catname"]} name of the topic; {timetodate ($ t ["addtime"], $ datetype )}? Release Date

9. others
You can use & template = to specify the tag template
If this parameter is not used, the default value is list.
In the tag Directory of the template directory
Level 1 of information level 1: Recommended articles; level 2: Slides; level 3: Recommended texts; level 4: Headlines; level 5: Headlines

Why? Tag calling reads the number of pagesize data records from the table according to the condition of the call, sorts the data by order, and finally uses the label mode...

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.