Sustainable Building
 .  Sourcebook
 .  Real Estate
 .  Professionals Directory
 .  Calendar
 .  Conferences
 .  Green Building Links
 .  Case Studies

Sustainable Reading
 .  Bookstore
 .  Articles

Sustainable Tourism
 .  Eco Travel in Latin America



Web Services
 .  Design
 .  Hosting
 .  FTP Access
 .  Domain Names
 .  E-Commerce
 .  Calendars
 .  Searchable Databases
 .  Search Engines
 .  Discussion Forums
 .  Webmaster Tips



Translate these pages



Contact Our Webmaster

Sustainable Building Green Building Calendar Green Building Professionals Directory Green Real Estate Classifieds Bookstore Internet Services

Sustainable Sources Logo

 


Webmaster Tips

Server Side Includes (aka NetCloak Macros)

Here's another nifty trick you can use to make your site easier to build and update.

Let's say your site has a couple of elements that are repeated on almost every page - a navigation bar, contact info at the bottom of each page, your logo, whatever.

You *could* build each page separately, plugging in that same code on page after page after page....

Or you could write each chunk of code once into a separate "include" file, and use what's known as a Server Side Include to plug it into the appropriate place on each page.

Later, when you decide to change the code in your navigation bar, you can change it one time in your include file and the change magically shows up everywhere.

Here's a quick example:

At the bottom of 30 pages, I want to place the following:

    <HR>

    <A HREF="mailto:info@greenbuilder.com">Webmaster</A> for this page is Bill Christensen.

    </BODY>
    </HTML>

Rather than playing copy/paste thirty times, I create a file called footer.incl and I place that at the same level as the pages that will be referring to it. Footer.incl has just the code above in it.

I then put the following code at the bottom of the page:

    <macro footer.incl>

(Note: this uses the NetCloak macro tag. If you're not hosted with Sustainable Sources or another server that uses NetCloak, you should be able to do something similar, but the syntax of the command will likely be different. Check with your web host)

When the page is served, NetCloak takes whatever code is in footer.incl, and places it in that spot. Change the code in footer.incl, and you've changed every page that uses it.

If you're using this technique on pages that are NOT at the same level as your include file, you'll need to use the full path from the server's root to your include file.

For example, the Straw Bale Association of Texas website has three include files - one for the header/logo, one for the nav bar, and one for the footer. They all live at http://www.greenbuilder.com/sbat/ . At the present time, all the SBAT pages live there too. But let's say we decide to post the newsletter archives, and wrap them in the same header/nav/footer includes. In order to keep things clean, we put the newsletters in their own folder within the SBAT folder. If we tried to put

    <macro footer.incl>

on one of those newsletters, the server would look for the file inside the /newsletters/ folder, and wouldn't find it there. Because the full path to the SBAT folder is www.greenbuilder.com/sbat/, the correct path would be:

    <macro /sbat/footer.incl>

(this same code could be used to insert the specified include text/code in ANY file on the greenbuilder.com server - though I don't know why you'd particularly want SBAT's footer on your site. "footer.incl" is not the actual name of SBAT's footer anyway, so don't expect the above example to work. Just try it out on your own site.)

For those of you who have your own domain names, you'll simply need to ask us for the path to your site. Usually it's just your site's name.

Home