Folder structure and file placement

Having problems with DHTML Menu? There is usually somebody here who knows the answer.
Post Reply
sartzava
Beginner
Beginner
Posts: 2
Joined: Sun Aug 22, 2004 9:39 pm

Folder structure and file placement

Post by sartzava »

I am building my website offline right now, but I have a question about file placement.

I currently have the following structure for my site's files:

Main folder
Subfolder
Subfolder
Subfolder

I currently have to place all four of the menu files in each of these folders to get the menu to work on the pages in them. Is there a way to set up the menu to only require one set of files for the entire site?
User avatar
John
 Team
 Team
Posts: 5967
Joined: Sun May 19, 2002 8:23 pm
Location: Phoenix, AZ
Contact:

Post by John »

Yes, easily.

Let's assume a slight change in your folder structure...

Main folder
Menu
->Subfolder
->Subfolder
->Subfolder

Place at least the 3 menu code files in /menu/. The _data file can be there as well, or in your HTML. It depends on how you are designing your site. For now we'll assume the _data file is in /menu/ as well.

Your JS calls would now look like this...

Code: Select all

<script language="javascript" src="/menu/milonic_src.js" type="text/javascript"></script>	
<script language="javascript" type="text/javascript">
if(ns4)_d.write("<scr"+"ipt language=javascript src=/menu/mmenuns4.js><\/scr"+"ipt>");		
else _d.write("<scr"+"ipt language=javascript src=/menu/mmenudom.js><\/scr"+"ipt>"); 
</script>
<script language="javascript" src="/menu/menu_data.js" type="text/javascript"></script>
This is server-relative addressing. Simply place this code on each of your pages, and the system will always look for the files in /menu/, regardless of your directory structure (assuming that /menu/ is at the same level as /Main folder/).
John
sartzava
Beginner
Beginner
Posts: 2
Joined: Sun Aug 22, 2004 9:39 pm

Post by sartzava »

John,

Thank you for the insight! Another issue that arises is the actual links within the menu. If I am linking from a page in subfolderA and to a page in subfolderB, I would need the link to be "../subfolderB/foo.html". However, that same link from a page in the main folder would need to be "subfolderB/foo.html".

How do I make the menu work correctly for this issue? The only thing that I can figure is to designate separate menu_data.js files for each subfolder, which is exactly what I don't want to do.

- Joshua
User avatar
John
 Team
 Team
Posts: 5967
Joined: Sun May 19, 2002 8:23 pm
Location: Phoenix, AZ
Contact:

Post by John »

You're welcome!

Just to be picky, our diagram isn't exactly right. Should be...

Main folder
->Subfolder A
->Subfolder B
->Subfolder C
Menu

Now, use the same info I gave you above to create a server-relative path. In this case, /Main folder/Subfolder B/foo.html. This will always start looking from the server root, regardless of where it is located in your structure.
John
Post Reply