Blogger Label List for FTP Accounts (Classic ASP)

*** MARCH 2010 UPDATE: Blogger no longer supports FTP accounts.***

For an overview on Blogger Label Lists read Blogger Label List for FTP Accounts (ASP.NET). Below is the code used to create a Label List using Classic ASP with VBScript.

Modify the first line to point to your label folder. Then correct the spelling of bl0gger-labels. It is purposely misspelled as to not throw off the count on this page. Save this code with a .asp file extension and then use a server-side include to place in onto your page template.

'-- add your label directory here
labelDir = Server.MapPath("/myblog/labels/")
'-- Check for Directory
Set FSO = Server.CreateObject("Scripting.FileSystemObject")

If FSO.FolderExists(labelDir) Then
    Response.Write "<ul>"
    Set labelFolder = FSO.GetFolder(labelDir)
    Set labelBlogs = labelFolder.Files
    For each label in labelBlogs
        Set labelFile = FSO.GetFile(label)
        Set labelStream = labelFile.OpenAsTextStream (1, -2)
        iLabelCount = 0
        '-- Read the file line by line

        Do While Not labelStream.AtEndOfStream
            Line = labelStream.readline
            LineCount = Sgn(InStr(Line,"bl0gger-labels"))
            iLabelCount = iLabelCount + LineCount
        Loop
        Response.Write "<li>" + Replace(labelFile.Name,".asp","") & " (" + CSTR(iLabelCount) & ")</li>"

        Set labelStream = nothing
        Set labelFile = nothing
    Next
    Response.Write "</ul>"

Else
    Response.Write "<p>No labels in folder: " & labelDir & "</p>"
End If

Set FSO = nothing

Below is an example of using a server-side include inside a Classic ASP page.

<div id="divLabelList">
<!--#include virtual="/inc/theme.asp"-->
</div>

Back in the day, Ev would have been proud of me.

This entry was posted in Classic ASP and tagged , , . Bookmark the permalink.

Comments are closed.