Digital Colony!

Blogger Label List for FTP Accounts (Classic ASP)

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.

Labels: , ,

AddThis Social Bookmark Button

4 Comments:

Blogger FUKUSHInet said...

Hi Michael,

I would like to use your code to show the label list on my sidebar in my blog (classic template, publishing on a ISP server via ftp)

Could you please advice to run the asp-script correctly ?

I follow your instruction so far but now:

1) where I have to place the .asp-file (I call it labellist.asp)

2) How I have to run the asp-script out of my classic html template, so that the label-list is shown in the sidebar ?

Thx for help

1/05/2008 3:43 AM

Blogger MAS said...

To start, you must be using the BLOGGER FTP Account. This will not work on hosted or BlogSpot accounts.

1 - modify this line to point to your label list folder path.
labelDir = Server.MapPath("/myblog/labels/")

2- First step is to get it working by itself in it's own page. Worry about the Blogger template later. You may make the list an ASP include file. Then once it is working, drop the Include reference into your Blogger template.

1/05/2008 6:15 AM

Blogger FUKUSHInet said...

Sorry to bother you.

Maybe I have to learn more about ASP before I can use your script :-(

Anyway:

1) My blog is hosted on server where I have ftp access to it (so this should be fine)
2) the labels are located at following path: /fukushinet/blog/labels

e.g. /fukushinet/blog/labels/silvester.html

(this should be fine as well)

3) I chance in the script the label list folder path to "/fukushinet/blog/labels/"

labelDir = Server.MapPath("/fukushinet/blog/labels/")

(this sould be fine also)

4) I stored the text with .asp on the server at path /fukushinet/blog , where my block is located.

5) when I try run the scrpt by typing the full http-path to the file just the content of the file (text) is returned to my browser

-> does this mean, the server support no asp-scripting ??

1/05/2008 10:05 AM

Blogger MAS said...

OK, it sounds like Blogger is publishing your LABEL pages with a .HTML extension. I was able to tweak Blogger to publish using .ASP extensions.

With this said, you can not embed an ASP script onto a .HTML page.

By default BLOGGER will not publish w/ an ASP extension. It needs to be tricked. In this article I outline 9 steps on how to trick it. Ignore the .NET stuff, the trick works with any file extension.

Blogger is a pain. If I had to do it over, I'd use WordPress.

1/05/2008 10:56 AM

 

Post a Comment

 

Digital Colony Copyright © 1999-2008 XHTML   508
This site uses Blogger, which is not 100% XHTML compliant.
Try...Catch Disclaimer: For brevity many examples do not include error handling. That is your responsibility.