|
This first solution is, technically, a hack. The nice thing about it is that it will work with just about any commercially available database on the market, and requires no external scripting or programming tools. However, it's not a very powerful system, and requires that you keep your base HTML code in the database itself. You may outgrow it if your needs become more sophisticated.
Let's assume that you've already created a simple database like the example above. Now take one of your site's perfect HTML pages and break it into chunks, separated by stuff that's the same on every page (globals) and stuff that's different on every page (variables), like this:
[global: code at the top of the document]
[variable: document title]
[global: body tag]
[variable: body color attribute of the body tag]
[global: more code until the headline]
[variable: the headline]
[variable: the author's name]
[variable: date]
[global: formatting code, such as <BLOCKQUOTE>]
[variable: the content itself]
[global: code at the bottom of the document]
Now create additional fields in your database for the global elements, name them something intuitive, and paste in the global code chunks from your template. Make sure you tell your database that these are global fields, so they show up in every single record, not just one. (In FileMaker, mark "global" in the Field Definition dialog. In Access, go into the table designer, mark the field as "memo," and enter your code in the Default Value field of the General tab, surrounding it with quotes. Note that in Access, this will only apply to new records, and won't automatically update those fields in the existing records you may have to do that manually the first time).
In essence, what you're doing here is setting things up so that when you view all of the fields for each record together as one unit, they comprise a complete HTML document. Once this is done, you'll want to export your records to plain text format. Consult your database documentation for instructions on this. If you open the text file, you'll find you've got a ton of HTML documents all concatenated into big file. You could now manually split the file into smaller documents, but fortunately, there's an easier way Microsoft Word includes an excellent file splitter that can do this for you faster than you can say "lickety split." If you're using a Macintosh, you can use AppleScript to loop through the database and export the files individually to begin with, rather than starting with one big file and exporting it manually.
If you'd like a much more detailed description of this technique, including details on Word's file splitter, see the tutorial "Data In, HTML Out."
Not into hacks? Looking for something a little more high-powered? I don't usually endorse specific products publically, but in this case, I'll make an exception. Why? Because a little utility called GDIdb (under $50), answered all my database-to-Web prayers, and I can't recommend it highly enough.
GDIdb is a small Windows program that opens up a connection to a database, sucks out the information you tell it to, inserts the appropriate data into template fields, and writes HTML documents to any number of folders, with any filenames you want. If you have a little programming experience, you can build scripts that perform any number of complex tasks. If you don't have programming experience, you can get fine results with its built-in Script Wizard. GDIdb works with most Windows databases and spreadsheets. It does not, however, work with FileMaker, because FileMaker doesn't speak Structured Query Language, or SQL the industry-standard language used for extracting specific information from databases.
While SQL is too deep a topic to get into here, the basic format of a SQL query is simple:
SELECT [FIELDNAMES] FROM [TABLENAME] WHERE [CRITERIA]
So if our sample database is in a table named "website" and we simply want all of its fields extracted, our SQL query looks like:
SELECT * FROM website
We don't need to specify any criteria, because we want everything, and "*" simply means "get all the fields." For our introductory purposes, "SELECT * FROM website" is all the SQL we need to know. If you want to learn more, the book SQL for Dummies provides an easy to understand and complete introduction.
I use GDIdb to generate three different sites: The Conspiracy of Sleepers Surrealist Dream Archive, The BeOS Tip Server, and The Archive of Misheard Lyrics. The GDIdb system I've developed for building these sites is capable of generating the 65-page Tip Server in under 4 seconds, and the 1400-page Archive of Misheard Lyrics, including 200 linked menus, in under five minutes. All I have to do is paste new content into my Access database, press one button, lean back in my chair, and watch it go. It's even capable of uploading the new site to my Web server. Heck, I can even schedule it to do everything in the middle of the night, unattended!
Let's say you've already got your site in a common database or spreadsheet. Install and fire up GDIdb, then pull down Utilities | Script Wizard. Answer the Wizard's questions one-by-one until you get to the end. When finished, GDIdb will open up your new script in Notepad. You'll see that it looks like standard HTML, but with some other weird stuff that you probably don't recognize. That's a combination of two things: special script commands for the GDIdb tool these begin with an ampersand ("&"), and tell it things like which database file to open, or scripting commands you don't need to worry about for now. You'll also see the field names from your database enclosed in question marks, such as ?author? and ?date?. If you click the Run button in GDIdb, it will run this script against your database and spit out an HTML file for each record.
Did you blink? It's incredibly fast. Click on HTML and your linking page will be launched in your browser. Click on a link and you'll be carried to a page containing a single database record, in HTML format. Kind of messy, isn't it? No big whoop all you need to do now is go into the script and paste the HTML code from one of your perfect pages into the appropriate places. Alternatively, you can paste GDIdb's code into one of your perfect pages, and make that your new script.
GDIdb has many, many more options not covered here. Consult the included documentation, help files, and especially the included demo scripts and databases to see just how powerful this tool is. It'll take you a bit to perfect your own system, but once you've got it dialed in, you may never have to code another page just add content to your database, fire up GDIdb, click Run, and upload your new site. Nirvana.
By day Scot Hacker (yes, that's his real name) is a Ziff Davis techno-weenie, but by night, he's a goateed motorcyle-riding poet. Or is it the other way around? Check out his funkadelic Web site, The Birdhouse Arts Collective.
|
|
|