Home
Products
Downloads
Support
Buy
Studio compiling and developing best practices
Product Name: WebMenu Studio
Product Version: 7.0
Document Type: Informational
Last Updated: 9/5/2016
Document ID: 68
Summary

There is more than one way to use WebMenu with the architecture of your web site. Your options for implementing WebMenu are as varied as the options that exist for web development in general.

If you are looking for some "best practices" guidance on implementing WebMenu, this document is for you.


Details

For a primer on paths, please see: Assistance with HTML paths

These are not "golden rules", but rather advice based on experience.

1. Do not use Relative Paths.

Despite what many basic HTML tutorials seem to imply, relative paths are not usually the best way to develop a maintainable website. You see them often in tutorials because they are good for distributing samples to run on any system. However, these samples are not typically built with maintenance in mind.

In fact, the samples included with WebMenu make use of relative paths for this same reason. These samples are distributed with the product download and are ready to run from any directory you place them.

Good for samples, bad for real-world website maintenance.

2. Use Root Relative Paths

This is the ideal method for specifying intra-site URL links and centralized resources on most websites. The web root is a common frame of reference no matter where resources reside in the directory structure.

3. Choose the location for the WebMenu *.js files

It is a common practice to place centralized libraries, such as the WebMenu *.js files, in an "/includes/" sub-directory of the web root. You may want to add another directory beneath that to store all of the WebMenu *.js files separate from other files, such as "/includes/mycontrol/".

When you add the SCRIPT statement to your pages to load the control, you will refer to the loader.js file using a Root Relative path:

<script src="/includes/mycontrol/loader.js" type="text/javascript"></script>

Now, no matter where the pages reside in the hierarchy of directories, the link to loader.js will work.

Internally, the WebMenu loader.js library also uses a path to locate web browser specific *.js files. This path is configurable in the "Options > Project Settings... > Compile" tab using the "Server include path" field. This should also be the equivalent Root Relative path as in your include statement, such as "/includes/mycontrol/".

4. Staging your website.

In an ideal situation, you will have a development server in which you will create and test your control before moving it to a production server. The website on the development server will be configured just like the website on the production server(s), and the same paths are always used between each server. That way, it is just a matter of compiling the WebMenu files for your development server, testing them and then moving them to your production server. Anything to eliminate having to change paths between development and production is a good thing. These days, with so much work being done in specialized server programming environments (ASP, ASP.NET, PHP, etc.), a properly configured development server is essential.

If you are working in standard HTML with no specialized server code, and you do not have a dedicated development server or even a local web server, you are probably relying on just opening the HTML files directly from your hard-drive and viewing them. This usually means that Root Relative paths will not be the same between your local hard-drive and your production server, because when opened files directly from a hard-drive, Root Relative paths will go to the drive letter as the "web root".

In Windows, there is an easy solution to making Root Relative paths work in both development and production environments without changing paths each time you update: The SUBST command.

The SUBST command creates a virtual hard-drive that begins from any directory you specify on your actual hard-drive. For instance, lets say the files for your website are in the following location:

C:\WebSites\MyBusiness\

"MyBusiness" represents the web root of your production server. Now, assuming that you do not already have an F: drive, you can create one using the SUBST command:

subst F: C:\WebSites\MyBusiness

The F: drive will appear on your system, and when you open it you will see the contents of the "MyBusiness" website in the root directory.

Now, when you compile WebMenu for the "MyBusiness" website, you can use the same Root Relative path between your local copy and the one on your production server. Just open your pages locally using the F: drive. If necessary, when you are finished using the F: drive you can remove the virtual mapping using:

subst F: /d

Copyright © 2024 Coalesys, Inc. All Rights Reserved.