Create an Extension Filter for a FileGenie Folder List Support
Question:
How can I filter my Folder List to only show specific extensions?
Answer:
If a displayed Folder List gets very long because of the number of files that are in the folder, it might be an option to put an Extension Filter on the page that contains the Folder List. When an extension from the filter is selected, only the files with the selected extension will be shown.
A Jump Menu with the extensions will be placed on the page. When an extension is selected the Jump Menu will post back to the same page with an URL parameter added. The Folder List will be filled depending on the extension in the URL parameter.
First, create a Folder List and have the content of this list appear on a page by creating a Folder List Repeater or a Folder List Table. Now add a Jump Menu by choosing Insert, Form, Jump Menu. Enter extensions by typing the extension in the Text field. In the field When selected, go to URL you type or select the current page, followed by the text ?e=EXT where the letters EXT to resemble the extension entered in the Text field. The e just stands for extension!
Start the extension list with two extra entries. The first one has --- in the Text field and nothing in the URL field. The second entry has ALL in the Text field and only the current page in the URL field, without the URL parameter. This will clear the filter on selection. When finished entering the extensions, click OK.
The last thing to do is add some code to have the Folder List only contain the files with the selected extension, depending on the URL parameter.
Switch to Code View and find the code for the Folder List. Add an If-statement before the Folder List code, which test if the URL parameter e is empty.
<% If Request.QueryString("e")="" Then %>
Scroll down and place your cursor directly below the List code. Insert an Else-statement. Now copy the Folder List code and paste it beneath the Else-statement. In this second code for the Folder List, edit the line .allowedExtensions to show the exension from the URL parameter.
.allowedExtensions = Request.QueryString("e")
Scroll down to the bottom of the second Folder List code and insert an End If-statement.
Your complete code could look like this:
<% If Request.QueryString("e")="" Then %>
<%
' *** Folder List 1.0.7
Set myfolderlist= New FolderList
With MyFolderList
.Path = "myfolder"
.allowedExtensions = ""
.includeFolders = false
.ShowThumbnailsOnly = false
.ThumbnailsSuffix = "_small"
.officeAttributes = false
.ReadFolder()
.SortOn "FileName", FG_SORT_ASCENDING
End With
%>
<% Else %>
<%
' *** Folder List 1.0.7
Set myfolderlist= New FolderList
With MyFolderList
.Path = "myfolder"
.allowedExtensions = Request.QueryString("e")
.includeFolders = false
.ShowThumbnailsOnly = false
.ThumbnailsSuffix = "_small"
.officeAttributes = false
.ReadFolder()
.SortOn "FileName", FG_SORT_ASCENDING
End With
%>
<% End If %>
That's basically it. Preview the result on a live page and see what happens!
I'd really appreciate your feedback on your results! If you have any more questions just let me know!
Comments
Be the first to write a comment
You must me logged in to write a comment.