how to articles

"Let The Computer Do The Work" series

(note: this article is a work in progress and was last updated 26-May-2005 . check back soon for the latest updates.)

Building Content using Folders and the Files In Them
using ASP FileSystem Object
(PHP coming soon)

STEP 4 Show Me! View the dynamic links when the Web page loads.

4. Enjoy the view! You Web pages will create-up-to-the-minute links to the files as the page loads.

Click here to see demo (opens in a separate browser window).

Each time the Web page loads (when a visitor visits the Web page) the list of links will be generated anew. Any file that you have added to the folder will be included on the Web page without any update to the Web page. Any files removed, too. This gives you control over the content without forcing you to make Web page updates to be up-to-the-minute.

For your complete reference, here is the complete BODY section of my demo Web page:

<body>
<h3>My Web Site</h3>

<h4>Classic Cars </h4>
<%
Set imgFSO = Server.CreateObject("Scripting.FileSystemObject")
thepath = Server.MapPath(Request.ServerVariables("PATH_INFO"))
thepath = LEFT(thepath, (LEN(thepath) - LEN(Request.ServerVariables("SCRIPT_NAME"))))
Set imgFolder = imgFSO.GetFolder(thepath & "\carimages")
%>
<%
Dim ImgArray()
ReDim ImgArray(500)
img = 0
For each thing in imgFolder.Files
ImgArray(img) = thing.name
img = img + 1
next
ReDim Preserve ImgArray(img - 1)
imgtop = img - 1
%>
<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0>
<%
idx = 0
for each car in ImgArray
%>
<TR><TD><A HREF="/carimages/<%=car%>" TARGET="_blank">
<%= LEFT(car, (LEN(car) - 4))%></A></TD></TR><%
next
%>
</TABLE>

</body>

Voila! You're done!

But ,doesn't that make you think of other things you might want to do?

And so, the next step is Step 5...