index | search | no replies | posting guidelines | help login | register
Index » General » Site & Forum Feedback
search this forum:
:: TreeView Contents of Web Directory Not clicakable :: (3)Post a New Message | Post a Reply
Jan 18 2006, 9:43 AM
 TreeView Contents of Web Directory Not clicakable Post a Reply
 KevMull

View this author's profile Send this author a private message

since: Jan 18, 2006
from: UK

I'm using the asp Treeview function to display a particular folder in my web.
It shows the folders as clickable which open up the contents OK, but these are just plain text and not clickable links.

How do I make them clickable links?

They are all files and not html (i.e. pdf, doc, ppt or txt files)
Also is there a way to show their appropriate image icon next to each file?
(I have all these as gif files)

Many Thanks

Jun 28 2006, 12:29 PM
 Re: TreeView Contents of Web Directory Not clic...Post a Reply
 joshuncc

View this author's profile Send this author a private message

since: Jun 28, 2006
from: somewhere

I need to know the answer to this myself. I am using the Treeview to display directory contents, but the files are not clickable.

Thanks for any help you have to offer.

- Josh

Jun 28 2006, 1:21 PM
 Re: TreeView Contents of Web Directory Not clic...Post a Reply
 joshuncc

View this author's profile Send this author a private message

since: Jun 28, 2006
from: somewhere

Okay, I decided to try to tackle this one on my own, and, well, I found a solution...

You will have to edit the file: clsTreeView.asp

Near the bottom you will find this:
-----------------------------------

    Private Sub ListFolderContents(objFolder,Parent)
        Dim objSubFolder, objFile    
        If Parent<>"0" Then
            Out ("<ul class=tree id=""N" & Parent & """>")
        Else
            Out ("<ul xstyle='margin-left:20px;' id=""N" & Parent & """>")
        End If    
        
        dim i
        For Each objSubFolder In objFolder.SubFolders
            Out("<li class=folder id=""P" & Parent & i & """><a class=treeview href=""javascript:toggle"& id &"('N" & Parent & "_" & i & "','P" & Parent & i & "')"">")
            Out objSubFolder.Name & "</a>"            
            Call ListFolderContents(objSubFolder,Parent & "_" & i)
            Out "</li>"
            i=i+1
        Next
        
        For Each objFile In objFolder.Files
            Out "<li class=file>" & objFile.Name & "</li>"
        Next
        
        Out "</ul>"
        
        Set objFile = Nothing
        Set objSubFolder = Nothing
    End Sub



-------------------------------------


I made some changes...here is the updated version below:

------------------------------------


    Private Sub ListFolderContents(objFolder,Parent)
        Dim objSubFolder, objFile    
        If Parent<>"0" Then
            Out ("<ul class=tree id=""N" & Parent & """>")
        Else
            Out ("<ul xstyle='margin-left:20px;' id=""N" & Parent & """>")
        End If    
        
        dim i
        For Each objSubFolder In objFolder.SubFolders
            Out("<li class=folder id=""P" & Parent & i & """><a class=treeview href=""javascript:toggle"& id &"('N" & Parent & "_" & i & "','P" & Parent & i & "')"">")
            Out objSubFolder.Name & "</a>"            
            Call ListFolderContents(objSubFolder,Parent & "_" & i)
            Out "</li>"
            i=i+1
        Next
        
        Dim url
        For Each objFile In objFolder.Files
            url = MapURL(objFile.path)
            Out "<li class=file><A href=""" & url & """>" & objFile.Name & "</A></li>"
        Next
        
        Out "</ul>"
        
        Set objFile = Nothing
        Set objSubFolder = Nothing
    End Sub
    
    function MapURL(path)
        dim rootPath, url
        
        'Convert a physical file path to a URL for hypertext links.
        
        rootPath = Server.MapPath("/")
        url = Right(path, Len(path) - Len(rootPath))
        MapURL = Replace(url, "\", "/")
    end function




-----------------------------------

As you can see, I added a MapURL funtion to the code.
I haven't attempted tinkering with the images though.

- Josh

Pages: (1)   [1]

search this forum: