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?
Folder structure and file placement
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...
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/).
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>
John
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
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
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.
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