Searchin'
April 5, 1999
The first weapon in your content management arsenal is a good
search-and-replace tool. Most Windows applications include such
a tool for use within a document, and it's wise to become
proficient with it. But you also need to be able to search
and replace across multiple files, in order to change common
page elements like logos or navbars. A good HTML Editor like
HomeSite (see
Homesite 4.0 Wins Coveted Web Developer's Journal "Product
of the Year, 1998: Award),
includes an extended search and replace option that allows you
to make changes to all files in specified directories. Become an
expert with this tool, and if you use your imagination you can
make quite complex global changes with it. Be careful though -
It's easy enough to screw up your whole site, so keep a backup.
There are times, however, when more sophisticated tools are
required. For example, what if you need to replace a block of
HTML that's similar but not exactly the same on every page?
If you're geeky enough, you can use scripting tools with regular
expressions and other tricks to make just about any changes you
can imagine.
Perl is great for this because it's quick and easy to write
sophisticated regular expressions and string manipulation
routines, once you get your head around the language. If you
have standard blocks of HTML you have to change often across
many pages, investing some time in writing a custom script to
automate those changes may pay off. Although Perl evolved out of
the Unix world, its popularity has spread to the PC, and there
are now very solid versions available for Windows 95/98 and NT.
No matter how handy you are with your search-and-replace
six-shooter though, it's a clumsy and limited tool for making
changes to common page elements. Let's say you've changed the
navbar that appears on every page of your thousand-page flat
site. Go into your HTML editor, perform the replace operation,
which will probably take a couple of minutes, then FTP all the
files to your server, taking another couple of minutes. Well,
at least it's done, right?
Maybe not, especially if someone in your organization has been
less than meticulous when editing files. If an element that's
supposed to be the same on every page isn't exactly the same,
it won't be fixed by your search and replace. You must be
ever-vigilant to avoid introducing spurious differences in
files, including such minutiae as extra line breaks or spaces.
A word about FTPing files: Be very careful to upload and
download files in the correct format: ASCII for Unix text files,
binary for everything else.
How much easier and more accurate it would be if you could
replace all the common elements like navbars, logos, headers,
footers, etc. with pointers to a single file. When one of these
elements needs to be changed, you simply change and upload one
file. And there's no danger of a page or two somewhere being
inconsistent. Fortunately, there's a quick and easy way to do
this, and you don't even need any special software, at least if
you use one of the major server packages.
Dynamic Systems
Content Management Tips and Tricks
On the Server Side of the Street
|