GPS How-To use it with Include Files
There are powerful reasons to put divaGPS code and your menus themselves into Include files if your server will allow it.
First, for our purposes the benefit is that you can have many pages on your site all include the information from a single file. This means instead of having the html code for your menus actually be on each and every page, you can put all that html markup in a single file and have it appear on each page as if it were actually there ON the page! You could then update all the menus by editing and uploading just that one page.
Same thing for divaGPS scripts. By placing its scripts in a single file and then Including that file in the head of each of your pages, you will be adding "you-are-here" highlighting to all your pages at once!
Next, can you do this? Well, if you are on a host that supports ASP, PHP, CF, or SSI, then you can do this. It might require a change in the file extension on all your pages though.
Read our article about Server-Side Includes & more to learn more about this subject. Additionally, you can visit these pages:
- http://www.freewebmasterhelp.com/tutorials/ssi
- http://www.4guysfromrolla.com/webtech/080199-1.shtml
- http://livedocs.macromedia.com/.../Using_Dreamweaver...
- http://httpd.apache.org/docs/2.0/howto/ssi.html
If you are new to this, do not be put off by its apparent complexity. Once you get the idea, it is very, very easy and incredibly powerful.
So, what to put in the Include file to add divaGPs to all your pages?
Open one page and add divaGPS to it. Then (in Dreamweaver open Code View) copy and delete the following code from the HEAD of the page.
<script type="text/javascript"><!--var gDivaGPS="(your parameters are in here)";//--></script><script type="text/javascript" src="/diva/divaCommon.js"></script><script type="text/javascript" src="/diva/divaGPS/divaGPS.js"></script>
Simply place the code, intact, into a new blank file (or into an existing Include file that is already used in the HEAD of your documents). There must be no HEAD, TITLE, BODY tags etc on this page. Save it as, for example "headscripts.inc" (or others, see our article or Links above for more on this.)
Then in the same spot from which you removed the code add the appropriate Include command.
- ASP, .NET and Apache with SSI
-
<!--#include virtual="/headscripts.inc" -->
- ColdFusion
-
<cfinclude template="/headscripts.inc">
- JSP
-
<%@ include file="/headscripts.inc" %>
- PHP
-
<?php include('/headscripts.inc'); ?>
We have not dealt here with path and other issues. Learn more about all this at the links provided.
Congratulations! You are building your website in a very efficient and flexible way.
Unobtrusive Scripts and Dreamweaver Extensions