ASP “Templating”

This is a follow-up to an earlier post about creating an easy-to-implement “templating” system in PHP that can be found at http://www.letsgomurphys.com/dailies/wp-trackback.php/4. At the time that was written, I promised an ASP version and here it is.

Over the last year or so, I’ve been using this successfully on over 30 domains as an alternative to Dreamweaver’s template system. I’m kind of eh about Dreamweaver. I think it’s file management system is handy. I like that I can rename a file and it’s dummy alert tells me other files are linked to that file, should it change the name in those files as well? Yes. Good, that was easy. To me, it beats manual find and replace. DW’s templates are useful when trying to maintain a consistent look and feel throughout a web site but if you want to change something you’ve got to have all the files that use that template, make the change, and reupload every file affected. Some of my sites have dozens and dozens and dozens of pages. Modifying and reuploading every file is time consuming and unnecessary. Enter the include.

I use includes to, well, include all consistent elements of a site. Using this technique, a sample page would look like this:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>World’s Greatest Web Page</title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
</head>
<body>

<!––#include virtual="/templates/hdr.asp"––>

<p>Welcome to the World’s Greatest Web Page!</p>

<!––#include virtual="/templates/ftr.asp"––>

</body>
</html>

In the above example, the contents of the hdr.asp and ftr.asp files are included in the page before the HTML parser sends everything to the browser window. They’ll contain all the design elements that appear on every page such as logo, global navigation, etc. The only contents of each page are it’s customized title and meta tags and its copy.

Now let’s take a look at the contents of hdr.asp:

<h1 id="logo">World’s Greatest Domain</h1>
<div id="nav">
<ul>
<li>Home</li>
<li>etc.</li>
<li>etc.</li>
</ul>
</div>
<div id="content">

This basically displays the logo (I usually use an image replacement technique here) and the navigation. Then I open the div that will contain all the content in the actual page.

The footer file is going to wrap up any open tags, such as the content div opened by hdr.asp, and contain any elements that semantically come after the content area such as sidebars and/or footers. Here’s what that looks like in this case:

</div><!–– close the content div ––>
<div id="bottomNav">
<ul>
<li>Home</li>
<li>etc.</li>
<li>etc.</li>
</ul>
</div>

That’s all there is to it. When the source of the page is displayed in a browser, everything gets put together and looks like this:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>World’s Greatest Web Page</title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
</head>
<body>

<h1 id="logo">World’s Greatest Domain</h1>
<div id="nav">
<ul>
<li>Home</li>
<li>etc.</li>
<li>etc.</li>
</ul>
</div>
<div id="content">

<p>Welcome to the World’s Greatest Web Page!</p>

</div><!–– close the content div ––>
<div id="bottomNav">
<ul>
<li>Home</li>
<li>etc.</li>
<li>etc.</li>
</ul>
</div>

</body>
</html>

This example is obviously extremely simplisitc but this technique can accomodate virtually any layout and is guaranteed to make updating a snap.

The next phase of my career

Citi logo

It’s been over two weeks since my last post, and here’s the reason. I’ve been offered and accepted a position at Citibank as an intranet developer for the student loan division. Over the last few weeks I’ve been trying to tie up loose ends and outstanding projects for my current employer and get oriented and start being productive for my new one. Because I’ll be developing strictly intranet sites, I’m not sure what I can disclose and what I can’t (especially since it’s a financial institution) but suffice to say that I have some rather challenging and very cool projects ahead.

It wasn’t an easy decision to make and leaving is bittersweet. I’m looking forward to loads of new opportunities but there’s also lots left that can be accomplished at WWWEnterprise, Inc. I want to thank everyone there for being so supportive and send everyone best wishes for the future. Hopefully posts will become more frequent again as I settle into my new responsibilities.

Halloween ideas

Ali G halloween costume

Ok, so it’s October 1st and Halloween will be here before anyone knows it. I thought I was pretty clever last year when I went as Ali G but I’m having trouble coming up with ideas to top it this year. Any suggestions?

Now Reading:

Persepolis 2: The Story of a Return

Persepolis 2: The Story of a Return by Marjane Satrapi

Defensive Design for the Web: How to improve error messages, help, forms, and other crisis points (V

Defensive Design for the Web: How to improve error messages, help, forms, and other crisis points (V by 37signals

GUI Bloopers 2.0: Common User Interface Design Don\\\’ts and Dos (Interactive Technologies)

GUI Bloopers 2.0: Common User Interface Design Don\\\’ts and Dos (Interactive Technologies) by Jeff Johnson

My Flickr

Mental ModelsWindsurfing @ VientoWindsurfing @ VientoWindsurfing @ VientoKiteboarding at Lincoln CityKiteboarding at Lincoln CityKiteboarding at Lincoln CityKiteboarding at Lincoln CityKiteboarding at Lincoln City