CoverYourASP --> Snippets

Free membership

Join in the fun! Sign in
Member Services

Site navigation
Download the entire site!
Search my articles
Free Magazines
Browse the directory

Send me feedback
Buy my boxer shorts

Recommend this page
Printer-friendly page

Resources I recommend
Link to my site
Advertising slashed!
About your privacy
Legal stuff
Site statistics
26 active users
1064 visitors today
921 pages today
(only part of today)
Tools I use

Copyright © 1999-2016 James Shaw.
All rights reserved.

RSS submissions

Now open source with SourceForge!

"Snippets" are mini-articles - they allow me to very quickly add answers to your frequently asked questions, and add brief explanations for topics that you've searched for without success. So, everytime you send an email or perform a search, chances are a new snippet will be the result!

22 Nov: How can I move some pages into sub-folders?

Ken Hough asked how to modify the CYA code so that he could run some pages from sub-folders. There would be some pages in the root (e.g. default.asp!), some in an Articles folder, some in a Members folder, etc.

First, keep the include and utils folders in the same place. Make two new files in the include folder - I call mine StartupRoot.asp and StartupChild.asp. Here are the contents of the files:


<%@ Language=JavaScript %>
var sRoot = '';   // we're running from the root folder

<!--#include file = "/Startup.html"-->


<%@ Language=JavaScript %>
var sRoot = '/..';   // we're running from a sub-folder

<!--#include file = "/Startup.html"-->

Then, include the relevant file in your pages. Instead of include/startup.asp, use include/StartupRoot.asp or ../include/StartupChild.asp

Lastly, anytime you need to reference a file in a particular folder, use sRoot. One place you'll certainly need to change is the database path in Config.asp:

var sDBPath = Server.MapPath ( sRoot + 'DBPATH/DB.mdb' );

Featured sponsor
My favorite resources

See my source code
wherever you see this icon...

You can also download the entire site source code for FREE!

CoverYourASP Mugs, T-shirts, caps - even Boxer shorts...
I don't make a penny from these, but they're a lot of fun! Don't you need a new mouse mat?