ASP under the implementation of tag, a simple introduction and part of the code _ application skills

Source: Internet
Author: User
Tags urlencode
What is tag (tag)?
Tags are a more free, flexible, user-determined classification rather than a traditional site-defined classification. You can according to their own understanding, the published articles, uploaded pictures, music, video and other documents to add one or more tags, flexible description.
What's the effect of tagging (tag)?
The label embodies the power of the group, enabling users to have more connections and interactions through similar content. You add tag when you publish a log or upload a file, and you can see all the logs and files that woku.com and you use the same tag.
What does the text of different sizes and weights in the label channel represent?
Use labels of different sizes and weights to represent the different frequencies used for labels. The larger and thicker the font, the higher the frequency with which these labels are used.
What do you need to be aware of when tagging?
① multiple labels, separate them with spaces.
② the maximum length of each label is 10 characters.
③ you can add up to 10 labels per log or file, including labels that you and other users add.
Can I add labels to the journals and files that are published by others?
You can determine whether a label can be added based on the Read permission of the browsing object. Public log or file, all users can add tags, only for friends to browse the log, only friends and authors can add tags, only the author can browse the log or file, only the authors can add tags. Of course, no matter who adds the tag, only the author of the log or file can modify or delete these tags.
So I found some ASP code to implement the tag function, for reference only
Copy Code code as follows:

'*********************************************************
' Purpose: Define the Ttag class
' Input: None
' Return: None
'*********************************************************
Class Ttag

Public ID
Public Name
Public Intro
Public order
Public Count


Public Property Get EncodeName
EncodeName = Server.URLEncode (Name)
End Property

Public Property Get Url
URL = Zc_blog_host & "Catalog.asp?" & "Tags=" & Server.URLEncode (Name)
End Property

Public Property Get Htmlurl
Htmlurl=transferhtml (Url, "[Html-format]")
End Property

Public Property Get Htmlintro
Htmlintro=transferhtml (Intro, "[Html-format]")
End Property

Public Property Get HTMLName
Htmlname=transferhtml (Name, "[Html-format]")
End Property

Public Property Get Rssurl
Rssurl = zc_blog_host & "sydication.asp?tags=" & ID
End Property

Public Function Post ()

Call Checkparameter (ID, "int", 0)
Call Checkparameter (order, "int", 0)

Name=filtersql (Name)
Name=transferhtml (Name, "[Normalname]")
If Len (Name) =0 Then post=false:exit Function

Intro=filtersql (Intro)
Intro=transferhtml (Intro, "[Html-format]")


If id=0 Then
objConn.Execute ("INSERT into [Blog_tag] ([Tag_name],[tag_order],[tag_intro]) VALUES (' &Name&" ', "&order & ", '" &Intro& ")"
Else
objConn.Execute ("UPDATE [Blog_tag] SET [tag_name]= '" &Name& "], [tag_order]=" &Order& ", [tag_intro]= '] &Intro& "' WHERE [tag_id] =" & ID)
End If

Post=true

End Function


Public Function Loadinfobyid (tag_id)

Call Checkparameter (tag_id, "int", 0)

Dim objRS
Set objrs=objconn.execute ("SELECT [Tag_id],[tag_name],[tag_intro],[tag_order],[tag_count] from [Blog_tag] WHERE [tag _id]= "& tag_id)

If (not Objrs.bof) and (not objrs.eof) Then

Id=objrs ("tag_id")
Name=objrs ("Tag_name")
Intro=objrs ("Tag_intro")
Order=objrs ("Tag_order")
Count=objrs ("Tag_count")

Loadinfobyid=true

End If

Objrs.close
Set objrs=nothing

If IsNull (Intro) Then intro= ""

End Function

Public Function Loadinfobyarray (arytaginfo)

If IsArray (arytaginfo) =true Then
Id=arytaginfo (0)
Name=arytaginfo (1)
Intro=arytaginfo (2)
Order=arytaginfo (3)
Count=arytaginfo (4)
End If

If IsNull (Intro) Then intro= ""

Loadinfobyarray=true

End Function


Public Function Del ()

Call Checkparameter (ID, "int", 0)
If (id=0) Then del=false:exit Function

Dim s
Dim I
Dim objRS

Set objrs=server.createobject ("ADODB. Recordset ")
Objrs.cursortype = adOpenKeyset
Objrs.locktype = adLockReadOnly
Objrs.activeconnection=objconn
Objrs.source= ""

Objrs.open ("SELECT [Log_id],[log_tag] from [blog_article] WHERE [Log_tag] like '%{' & ID & '}% '")

If (not Objrs.bof) and (not objrs.eof) Then
Do as Not objrs.eof
I=objrs ("log_id")
S=objrs ("Log_tag")
S=replace (S, "{" & ID & "}", "")
objConn.Execute ("UPDATE [blog_article] SET [log_tag]= '" & S & "' WHERE [log_id] =" & i)
Objrs.movenext
Loop
End If
Objrs.close

objConn.Execute ("DELETE from [Blog_tag] WHERE [tag_id] =" & ID)
Del=true
End Function


Public Function maketemplate (s)

S=replace (S, "< #article/tag/id#>", id)
S=replace (S, "< #article/tag/name#>", HTMLName)
S=replace (S, "< #article/tag/intro#>", Htmlintro)
S=replace (S, "< #article/tag/count#>", count)
S=replace (S, "< #article/tag/url#>", Htmlurl)
S=replace (S, "< #article/tag/encodename#>", EncodeName)

Maketemplate=s

End Function


End Class
'*********************************************************


'*********************************************************
' Purpose: Tags read
'*********************************************************
Function GetTags ()

Dim i,j,k,l

Dim Aryalldata
Dim Arysingledata ()

Erase Tags

Dim objRS

Set objrs=objconn.execute ("select top 1 [tag_id] out [Blog_tag] ORDER BY [tag_id] DESC")
If (not Objrs.bof) and (not objrs.eof) Then
I=objrs ("tag_id")
ReDim Tags (i)
End If

Set objrs=objconn.execute ("SELECT [Tag_id],[tag_name],[tag_intro],[tag_order],[tag_count] from [Blog_tag] TAG_ID] ASC ")
If (not Objrs.bof) and (not objrs.eof) Then

Aryalldata=objrs.getrows (Objrs.recordcount)
Objrs.close
Set objrs=nothing

K=ubound (aryalldata,1)
L=ubound (aryalldata,2)
For I=0 to L
Set Tags (Aryalldata (0,i)) =new Ttag
Tags (Aryalldata (0,i)). Loadinfobyarray (Aryalldata (0,i), Aryalldata (1,i), Aryalldata (2,i), Aryalldata (3,i), Aryalldata (4,i))
Next

End If

Gettags=true

End Function


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