Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Jun 2011
    Location
    Phnom Penh, Cambodia
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Cool ASP tag cloud code example

    Hello

    Today, popular site has simple tag cloud for their site. Such as News. However, i found rarely Classic Tag Cloud on net for Asp.

    I get a code for my news site. I want to generate tag for all title of news. but I cant make it work, anybody can help?

    My Live site - www.cambodia-tourism.org/news

    Code:
    <%
    
    Function GenerateTagCloud(arrAllTags)
      Dim strReturn
      Dim strUrlPrefix
      Dim intLoop
      Dim objDictionary
      Dim strTag
      Dim colKeys
      Dim strKey
      Dim strStyleSize1
      Dim strStyleSize2
      Dim strStyleSize3
      Dim strStyleSize4
      Dim strStyleSize5
      Dim strStyleSize6
      Dim strStyleSize7
      Dim lngHighestTagCount
      Dim lngLowestTagCount
      Dim dblDiff
      Dim dblStep
      Dim dblOffset
      Dim dblBorder1
      Dim dblBorder2
      Dim dblBorder3
      Dim dblBorder4
      Dim dblBorder5
      Dim dblBorder6
      strUrlPrefix = "/?"
      strStyleSize1 = "font-size: 9px;"
      strStyleSize2 = "font-size: 10px;"
      strStyleSize3 = "font-size: 12px;"
      strStyleSize4 = "font-size: 14px;"
      strStyleSize5 = "font-size: 14px; font-weight: bold;"
      strStyleSize6 = "font-size: 16px; font-weight: bold;"
      strStyleSize7 = "font-size: 18px; font-weight: bold;"
      Set objDictionary = Server.CreateObject("Scripting.Dictionary")
      For intLoop = 0 to Ubound(arrAllTags)
        strTag = arrAllTags(intLoop)
        If objDictionary.Exists(strTag) = True Then
          objDictionary.Item(strTag) = objDictionary.Item(strTag) + 1
        Else
          objDictionary.Add strTag, 1
        End If
      Next
      lngHighestTagCount = 1
      lngLowestTagCount = 2147483647
      colKeys = objDictionary.Keys
      For Each strKey in colKeys
        If objDictionary.Item(strKey) > lngHighestTagCount Then
          lngHighestTagCount = objDictionary.Item(strKey)
        End If
        If objDictionary.Item(strKey) < lngLowestTagCount Then
          lngLowestTagCount = objDictionary.Item(strKey)
        End If
      Next
      dblDiff = (lngHighestTagCount-lngLowestTagCount)
      dblStep = (dblDiff-(dblDiff/7))/5
      dblOffset = dblDiff/14
      dblBorder1 = lngLowestTagCount+(dblstep*0)+dblOffset
      dblBorder2 = lngLowestTagCount+(dblstep*1)+dblOffset
      dblBorder3 = lngLowestTagCount+(dblstep*2)+dblOffset
      dblBorder4 = lngHighestTagCount-(dblstep*2)-dblOffset
      dblBorder5 = lngHighestTagCount-(dblstep*1)-dblOffset
      dblBorder6 = lngHighestTagCount-(dblstep*0)-dblOffset
      For Each strKey in colKeys
        If objDictionary.Item(strKey) < dblBorder1 Then
          objDictionary.Item(strKey) = strStyleSize1
        ElseIf objDictionary.Item(strKey) > dblBorder1 And _
            objDictionary.Item(strKey) < dblBorder2 Then
          objDictionary.Item(strKey) = strStyleSize2
        ElseIf objDictionary.Item(strKey) > dblBorder2 And _
            objDictionary.Item(strKey) < dblBorder3 Then
          objDictionary.Item(strKey) = strStyleSize3
        ElseIf objDictionary.Item(strKey) > dblBorder3 And _
            objDictionary.Item(strKey) < dblBorder4 Then
          objDictionary.Item(strKey) = strStyleSize4
        ElseIf objDictionary.Item(strKey) > dblBorder4 And _
            objDictionary.Item(strKey) < dblBorder5 Then
          objDictionary.Item(strKey) = strStyleSize5
        ElseIf objDictionary.Item(strKey) > dblBorder5 And _
            objDictionary.Item(strKey) < dblBorder6 Then
          objDictionary.Item(strKey) = strStyleSize6
        ElseIf objDictionary.Item(strKey) > dblBorder6 Then
          objDictionary.Item(strKey) = strStyleSize7
        End If
      Next
      For Each strKey in colKeys
        strReturn = strReturn & "<a href=""" & strUrlPrefix & _
          strKey & """ style=""" & objDictionary.Item(strKey) & _
          """>" & strKey & "</a> " & vbcrlf
      Next
      Set objDictionary = Nothing
      GenerateTagCloud = strReturn
    End Function
    
    %>
    references for code: http://www.808.dk/?code-asp-tag-cloud

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    27,159
    Thanks
    80
    Thanked 4,559 Times in 4,523 Posts
    Worked fine for me.

    You probably aren't using it right.

    But since you don't show *HOW* you are using it, how can we guess?

    No code, no help.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #3
    New Coder
    Join Date
    Jun 2011
    Location
    Phnom Penh, Cambodia
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hello Old Pedant

    Thank for quick tips, I just copy all code above put in my site.
    Actually Tag Cloud Generate from Keywords for news: Title, Description, Keywords

    Can we have like: /news/tag.asp?id=travel what we have to config for

    - & strUrlPrefix & _ strKey & "

  • #4
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    27,159
    Thanks
    80
    Thanked 4,559 Times in 4,523 Posts
    Sorry, I don't understand what you mean.

    You mean you want to create a cloud for the words "travel what we have to config for" ???

    I don't think you mean that.

    I say again, show your code. How are you *CALLING* that GenerateCloudTag function??
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •