Dedecms calls the TAG of the current article on the document/table page

Source: Internet
Author: User
Tags join tagname urlencode

I will not introduce the dedecms which has a dede: tag. We can use it directly.


Call the tags tag of the current article and perform a secondary development.

The code is as follows: Copy code

If (! Function_exists ('gettags ')){
Function GetTags ($ aid)
{
Global $ dsql;
$ Tags = ";
$ Query = "SELECT tag FROM '##__ taglist' WHERE aid = '$ aid'";
$ Dsql-> Execute ('tag', $ query );
While ($ row = $ dsql-> GetArray ('tag '))
{
$ Tags. = ($ tags = "? $ Row ['tag']: ','. $ row ['tag']);
}
Return $ tags;
}
}
Replace with: // 111cn.net
If (! Function_exists (")){
Function GetTags ($ aid ){
Global $ dsql;
$ Tags = ";
$ Query = "SELECT tag FROM '##__ 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> www.111cn.net ":','. "<a href =/tags. php? /{$ Row ['tag']} target = _ blank >{$ row ['tag']} </a> ");
}
Return $ tags;
}
}

Call the tags tab on the open table page to find a reference

Add the following code as needed on the list template page

The code is as follows: Copy code

[Field: id runphp = yes]
$ Tsql = new DedeSql (false );
$ Tags = "";
$ Tsql-> SetQuery ("Select I. tagname From dede_tag_list t left join dede_tag_index I on I. id = t. tid where t. aid = '@ me '");
$ Tsql-> Execute ('t ');
While ($ row = $ tsql-> GetArray ('t', MYSQL_ASSOC )){
$ Tags. = "<a href = '/tag. php? /". Urlencode ($ row ['tagname']). "'> ". $ row ['tagname']. "</a>" ;}@ me = $ tags;
[/Field: id]

Please note that the relevant table names are correct. If you have modified the relevant table names, you must modify them here.

Or write it directly in include/common. func. php for processing.

Step 1: Open the root directory of the website program and find the file: include/common. func. php.

Add the following code at the bottom:

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;
}
 

Step 2: use the tag {dede: field. id function = "listtag (@ me)"/} to call the TAG. On the list page, you can use [field: id function = "listtag (@ me) "/] to call the TAG of the article page.
 

Step 3: The dede list page is now successfully resolved to call the article tag.

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.