Destoon Official Label Encyclopedia _php Example

Source: Internet
Author: User
Tags add time function prototype

What is a tag call?

A tag invocation reads the number of calls (pagesize) from a datasheet (table) based on the invocation condition (condition) and sorts by sort order, eventually outputting the data through the layout of the label template.
As you can see, the label's work is divided into two parts, one is to read the data, and the other is to display the data.
Label function prototype

tag function stored in include/tag.func.php
Tag ($parameter, $expires = 0)
$parameter represents a string passed to the tag function that the system automatically converts to multiple variables
such as passing Table=destoon&pagesize=10&hello=world
System is equivalent to getting
$table = ' Destoon ';
$pagesize = 10;
$hello = ' world ';
Three variables
$expires indicates that the label cache expiration >0 cache $expires seconds, 0– system default label cache time, -1– not cache, -2– cache SQL results;
The general situation remains the default and does not need to be passed.


Data read process

For example, the following tags:

<!–{tag ("Table=sell&condition=status=3&order=addtime Desc&pagesize=10″")}–>

will be converted to the following SQL statement:

SELECT * from
Destoon_sell
WHERE status=3 ORDER by
addtime DESC
LIMIT 0,10

The data read will be stored in the $tags array.
Data display Process

1, through the label template display
Pass &TEMPLATE=ABC to the label function, for example:

<!–{tag ("Table=...&template=abc")}–>

The default label template is saved in the template directory/tag/directory, for example, &TEMPLATE=ABC will call the template directory/tag/abc.htm template to display the data
If the label template is placed in a different directory, such as Def, the &DIR=DEF&TEMPLATE=ABC is passed, and the template directory/def/abc.htm template is called

2, directly in the template loop data

<!–{php $tags =tag ("Table=...&template=null");} –>


This writing passes the label template to null and returns the data directly to the $tags array, which can be cycled directly in the template.
The following is a complete example:

<!–{php $tags =tag ("Table=...&template=null");} –>
{loop $tags $t}
...
{/loop>

The first method is commonly used for multiple invocations of data, and the second is typically used for data that is invoked only once.
Common parameters and meanings

ModuleID
ModuleID refers to the module ID, which can be queried in the background module management. For data that directly invokes the module, the correct module ID is not required to pass the table parameter, and the system is automatically fetched.
For example, passing moduleid=5, the system will be recognized as invoking the provisioning information, automatically setting the table parameter to sell

table
Table refers to the list name, which can be queried in the background database maintenance. For Destoon system tables, you do not need to prefix the table, and for a destoon system table, you need to complete the table name and pass the prefix parameter
For example, for Destoon system tables, pass Table=sell, and if the table prefix is destoon_, the system will recognize the table name as Destoon_sell
For Destoon system tables, passing table=tb_abc&prefix= or table=abc&prefix=tb_, the system will recognize the table name as Tb_abc

Fields
Fields refers to the field of the query, which defaults to *. such as Fields=title,addtime can be passed, but in general there is no need for delivery, Destoon unique tag caching mechanism automatically caches query results without worrying about efficiency issues.

condition
Condition refers to the condition of the query, or 1, if not passed, that represents the data for any condition (this item needs to understand SQL syntax). Destoon All modules follow the unified standard development, so many conditions are generic.
For example, status=3 represents information that is normally passed, status=3 and level=1 represents information of level 1, status=3 and thumb<> "represents information for a caption picture, and so on."

Order
Order refers to the sorting method of the data (this item needs to understand SQL syntax).
For example Order=addtime desc means descending by add time, Order=itemid desc means descending by itemid, Order=rand () representing random data, and so on.

pagesize
PageSize refers to the number of call data, which defaults to 10 if not passed.

Template
Template refers to the specified label template, if not passed, the default is list, located in the template directory/tag/list.htm, if passed to null, the label template is not applied. See the above data display process.
Other common usage examples

Multi-table Joint query
For example, members and company information of the member named Destoon can be used:

{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 of the tables (including the table prefix), prefix= "indicates that the system no longer automatically prefix the table name

control title length
Passing the length parameter in the label, such as &length=20 for 20 characters (2 characters), is generally recommended to hide extra characters (define height and Overflow:hidden) with CSS
Pass the length parameter. The system only intercepts the title field automatically, if you need to intercept other fields, you can use the DSUBSTR function
For example {dsubstr ($t [Company], 20, ' ... ')} to intercept the company field is 20 characters, after interception, the end of the append ...

Set date display format
can pass the Datetype parameter in the label:
1 for year;
2 for month-day;
3 for year-month-day;
4 for month-day: minute;
5 means year-month-day:
6 for year-month-day: minutes: SEC
You can also use the DATE function directly in the template, for example, {date (' y-m-d ', $t [Addtime])} represents converting time to year-month-day format

calls a category of information
to pass CATID parameters in the label, for example, &catid=5 represents all information calling the category ID 5.
If multiple classifications are invoked, the category IDs are separated by commas, for example, &catid=5,6,7 represents all information that calls the category ID 5, 6, 7. The
Classification call defaults to the information that contains subcategories, and you can set the &child=0 parameter if you do not need to include subcategories.
For example, &catid=5&child=0 indicates that only information with a taxonomy ID of 5 is invoked, excluding the information for subcategories. The

call information for a region
calls the area information exactly the same way that the classification information is invoked above, swapping the CATID for areaid.

Display information in categories

<a href= ' {$MODULE [$moduleid][linkurl]}{$CATEGORY [$t [Catid]][linkurl]} ' >{$CATEGORY [$t [Catid]][catname]} </a>

Control Number of columns
This item is commonly used in the layout of pictures, and you can use the cols parameter.
For example, call 12 pictures, one row shows 4, a total of 3 rows, then pass &pagesize=12&cols=4
Label template limits thumb-table.htm and list-table.htm that support cols parameters
Where thumb-table.htm displays a list of pictures, list-table.htm displays a list of words
If you create a new cols label template or direct loop $tags, refer to the above two templates
The above effects can also be implemented through CSS, without using the table, please write your own

show an introduction to the article
Using the {$t [introduce]} variable, if you want to intercept the number of words, such as 80 characters, you can use {dsubstr ($t [introduce], 80, ' ... ')}

function prototypes
Tag ($parameter, $expires = 0)
$parameter represents a string passed to the tag function that the system automatically converts to multiple variables
such as passing table=destoon&pagesize=10, the system is equivalent to getting $table = ' destoon '; $pagesize = 10; two variables
$expires indicates cache expiration time
>0 cache $expires seconds; 0– system default time; -1– not cache; -2– cache SQL; Generally, keep the default.

Constants
{Dt_skin}
System style URL.
{Dt_path}
Home Page Web site.

Variable
$tags
The data that the tag invocation is saved as an array type can be traversed through the loop syntax.
$pages
Saves the data paging code, which is only valid when paging is called.
$MODULE [5][name]
The name of the module with ID 5.
$MODULE [5][linkurl]
Module URL with ID 5.
$CATEGORY [5][catname]
Category name with ID 5 (valid only if the variable $category exists).
$CATEGORY [5][linkurl]
Category URL with ID 5 (valid only if the variable $category exists).

commonly-in fields
Title titles; Linkurl links; CatID classification ID; introduce introduction; Addtime add time; common functions Dsubstr ($string, $length, $suffix = ")
Intercepts the string $string to $length long, with the tail appended $suffix (for example ...)
Date ($format, $timestamp)
Convert timestamp $timestamp to $format (for example, y-m-d) format

Label Template
Template is stored in the./template/default/tag/directory;
It is recommended that you do not delete or modify your own template, and recommend that you create a new template based on your template and apply it.

1. General description of label format

<!–{tag ("moduleid=9&table=article_9&length=40&condition=status=3&pagesize=10&datetype=2 &order=addtime Desc&target=_blank ")}–>

Moduleid=9 is the information module ID, module ID to the module management view;
Article is the directory name of the information module;
&LENGTH=40 is the label intercept word number
&PAGESIZE=10 is the number of call bars
&datetype=2 is to show time to add time

2. Call Latest Join Enterprise

<!–{tag ("Moduleid=4&table=company&condition=groupid>4&pagesize=10&order=userid desc& Template=list-com ")}–>

3. How to call one of the corporate members of the supply and demand and information
In condition= riga and username= ' xxx '? XXX is a member login name

4. How to call a product under the purchase of a category
The information under the call category can be set &catid= industry id&child=1 Child=1 indicates that the subordinate industry is also being invoked

5. Call level two column information list

<!–{tag ("moduleid= $moduleid &table=article_$moduleid&catid= $catid &child=1
&condition= Status=3&order= ". $MOD [order]." &pagesize=6&datetype=2&target=_blank ")}–>

If you are calling in the article module you can use the above code $catid change to the column ID you want to call
If you need to call the information in the column at the same time child=1, otherwise child=0
If you are calling elsewhere on the site, you can use the following code:

<!–{tag ("Moduleid=9&table=article_9&catid= $catid &child=1&condition=status=3&order= Addtime Desc&pagesize=6&datetype=2&target=_blank ")}–>

Note that the value of the ModuleID is consistent with the module ID you are calling
Add:
The following is a successful call on the home page

<!–{tag ("Moduleid=9&table=article_9&catid= $catid &child=1&condition=status=3&order= Addtime Desc&pagesize=6&datetype=2&target=_blank ")}–>

But I want a list of templates inside the information page, which shows only 22 words per article.

6. Homepage information column how to call here
"9" is the ID of your module

{php $C = get_maincat (0, Cache_read (' category-9.php '));}
{Loop $C $k $v}
<a href= "{$MODULE [9][linkurl]}{$v [Linkurl]}" >{$v [catname]}</a>
{/loop}


7. List of companies can not control the number of words!!
You can directly modify list-com.htm
{$t [company]} to {dsubstr ($t [Company], $length)}

8.TAG common label
{$CATEGORY [$t catid]]["CatName"]} belongs to the column name; {timetodate ($t ["Addtime"], $datetype)}? Release Time

9. Other
You can specify the label template by &template=
if it doesn't work. This parameter defaults to the list
located in the template Catalog tag directory
Level 1 for the recommended article; 2 level for the slide picture; Level 3 for the recommended text, level 4 for the headlines, 5 for the headlines related

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.