The implementation of tag under asp, a brief introduction and some code

Source: Internet
Author: User

What is a Tag?
Tags are a more flexible and user-dependent classification method, rather than a website-defined classification method. Based on your understanding, you can add one or more tags to various files such as published articles, uploaded images, music, and videos for flexible description.
What is the role of adding tags?
Tags reflect the power of groups, allowing users to create more associations and interactions through similar content. After you add tags when posting logs or uploading files, you can see all the logs and files that use the same Tag as woku.com.
What are the characters of different sizes and thicknesses in the tag channel?
Labels of different sizes and font thicknesses indicate the frequency of use of tags. The larger the font size, the higher the usage frequency of these labels.
What do you need to pay attention to when adding tags?
① Separate Multiple labels with spaces.
② The maximum length of each label is 10 Chinese characters.
③ You can add up to 10 tags for each log or file, including the tags added by yourself and other users.
Can I add tags to logs and files posted by others?
You can determine whether tags can be added based on the reading permission of the browser object. For public logs or files, all users can add tags. For logs viewed by friends only, tags can be added only by friends and authors. For logs or files that can be viewed by authors only, only the author can add tags. Of course, no matter who adds tags, only the author of the log or file can modify or delete these tags.
So I found some asp code that implements the tag function for reference only. Copy codeThe Code is as follows: '*************************************** ******************
'Purpose: to 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 While 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: to read Tags
'*************************************** ******************
Function GetTags ()

Dim I, j, k, l

Dim aryAllData
Dim arySingleData ()

Erase Tags

Dim objRS

Set objRS = objConn. Execute ("select top 1 [tag_ID] FROM [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] order by [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 (Array (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.