Dedecms call tag implementation method and detailed analysis

Source: Internet
Author: User
Tags rand

1. Call all the tag methods on this site.

This official notes
Method 1:

The code is as follows: Copy code

{Dede: tag type = 'current '/}

After generation: tag tags (number of tags)

Method 2:

The code is as follows: Copy code

{Dede: tag sort = 'new' getall = '0' row = 60}
<A target = "_ blank" href = '[field: link/]'> [field: tag/] </a>
{/Dede: tag}

Supplement:

The code is as follows: Copy code

Latest tag

{Dede: tag row = '30' sort = 'new'} [field: tag/] {/dede: tag}

Popular tags for current month

{Dede: tag row = '30' sort = 'month'} [field: tag/] {/dede: tag}

Random tag

{Dede: tag row = '60' sort = 'Rand'} [field: tag/] {/dede: tag}


Note:

Row: number of calls.
Sort: sorting method. Parameters include month, rand, week, and new.
Getall: Get type. Parameters: 0 and 1. 0 indicates the current content page or topic page tag, and 1 indicates obtaining the full site tag.

2. Call the tag of the current page of the article

Add the {dede: field. tags/} Tag to the article template, but the default Tag of dedecms is not linked.

Add a hyperlink to a Tag
Find http://www.111cn.net/include/helpers/archive.helper.php under the website and directory, and find rows in the left-right corner.

The code is as follows: Copy code

If (! Function_exists ('gettags '))
{
Function GetTags ($ aid)
    {
Global $ dsql;
$ Tags = '';
$ Query = "SELECT tag FROM 'dede _ taglist' WHERE aid = '$ aid '";
$ Dsql-> Execute ('tag', $ query );
While ($ row = $ dsql-> GetArray ('tag '))
        {
$ Tags. = ($ tags = ''? $ Row ['tag']: ','. $ row ['tag']);
        }
Return $ tags;
    }
}

Replace it with the following code:
If (! Function_exists ('gettags '))
{
Function GetTags ($ aid)
    {
Global $ dsql;
$ Tags = '';
$ Query = "SELECT tag FROM 'dede _ taglist' WHERE aid = '$ aid '";
$ Dsql-> Execute ('tag', $ query );
While ($ row = $ dsql-> GetArray ('tag '))
        {
$ Tags. = ($ tags = ''? '<A href =/tags. php? /'. $ Row ['tag']. 'Target = _ blank>'. $ row ['tag']. '</a> ':','.'
<A href =/tags. php? /'. $ Row ['tag']. 'Target = _ blank>'. $ row ['tag']. '</a> ');}
Return $ tags;
}}

3. Call the tag label method of this topic

Open the DEDECMS root directory include/common. func. php

At the bottom?> Add the following code:

The code is as follows: Copy code


Function listtag ($ aid)
{
$ Tsql = new DedeSql (false );
$ Tags = '';
$ Tsql-> SetQuery ("Select I. tag From dede_taglist t left join dede_tagindex I on I. id = t. tid where t. aid = '$ aid '");
$ Tsql-> Execute ('t ');
While ($ row = $ tsql-> GetArray ('t', MYSQL_ASSOC )){
$ Tags. = "<a href = '/tags. php? /". Urlencode ($ row ['tag'])."/'> ". $ row ['tag']." </a> ";
}
Return $ tags;
}

2. You can use 21 on the article page.

{Dede: field. id function = "listtag (@ me )"/}


To sum up, dedecms is not suitable for calling the tag below in the article. Currently, seo/seo.html "target =" _ blank "> The website has been optimized, so we need to make improvements.

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.