Destoon official tag Daquan _ php instance

Source: Internet
Author: User
Tags add time
This article mainly introduces the destoon tag. For more information, see 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 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 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 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 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 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 indicates the number of data calls. If not passed, the default value is 10.

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


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.

System style URL.
Website homepage URL.

$ 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.
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

Related Article

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.