sub directories

Having problems with DHTML Menu? There is usually somebody here who knows the answer.
Post Reply
noel dubau
Beginner
Beginner
Posts: 3
Joined: Sun Jan 04, 2004 7:40 am

sub directories

Post by noel dubau »

Excuse my approximative english !
The problem is the following one : In the directory of my site are many sub directories ; must I put in every one all the .js files ? Or is there a syntax to say that tje .js files are in a directory above the current one ?
Thanks for your help.
Noël
User avatar
Hergio
Milonic God
Milonic God
Posts: 1123
Joined: Wed Jun 12, 2002 7:46 pm
Location: Rochester, NY

Post by Hergio »

Yes it can be done and should be done that way. That way you have one copy of the menu and all the pages use it, so when you make a change, all the menus "see" it.

Basically when you say src="" in your menu includes, put the address of the menu code in there, and include your server address. (i.e. http://www.yourdomain.com/menucode/mmenudom.js) that way no matter what page is using the menu code, you can get to it. See this little post that John put some effort into to explain some addressing issues. For further help, do a search on the forums for "addressing" and "path" or "relative" and "absolute".

viewtopic.php?t=1983
Dave Hergert
Software Engineer
"Helping to make the menu better, one :?: at a time."
User avatar
timrivera
Super Advanced
Super Advanced
Posts: 31
Joined: Sun Jan 04, 2004 8:21 pm
Location: Metro-Atlanta, Georgia, USA
Contact:

Re: sub directories

Post by timrivera »

noel dubau wrote:must I put in every one all the .js files ? Or is there a syntax to say that tje .js files are in a directory above the current one ?
You don't have to include the full URL as Hergio suggested, just make reference relative to the root directory, i.e. src="/menu/*.js". Or if all the .js files are just one directory above all the pages that will use the menu, you can write the reference as src="../menu/*.js".

One important note is that the arrow images must also have a relative path defined from the page that uses the menu. I am about to use the menu on various directory levels, therefore I define the location of the .js files relative to the root directory, and in the menu_data.js and mmenuns4.js files I also define the location of the arrow images relative to the root.


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

Re: sub directories

Post by John »

timrivera wrote:Or if all the .js files are just one directory above all the pages that will use the menu, you can write the reference as src="../menu/*.js".
Not a good idea, especially if the site goes more than one level deep. Then you wind up with ../../menu, ../../../menu, etc. Server relative is the best way to go.
John
User avatar
timrivera
Super Advanced
Super Advanced
Posts: 31
Joined: Sun Jan 04, 2004 8:21 pm
Location: Metro-Atlanta, Georgia, USA
Contact:

Re: sub directories

Post by timrivera »

jgillett wrote:Not a good idea, especially if the site goes more than one level deep.
That's why I said "if all the .js files are just one directory above" in response to the original question of "Or is there a syntax to say that the .js files are in a directory above the current one ?"

Oh, and all the links in the menu have to be relative to the root also (or absolute).
User avatar
John
 Team
 Team
Posts: 5967
Joined: Sun May 19, 2002 8:23 pm
Location: Phoenix, AZ
Contact:

Re: sub directories

Post by John »

timrivera wrote:That's why I said "if all the .js files are just one directory above" in response to the original question of "Or is there a syntax to say that the .js files are in a directory above the current one ?"
Hmmm - sorry, missed that small detail.
timrivera wrote:Oh, and all the links in the menu have to be relative to the root also (or absolute).
Absolutely :!: :roll:
John
noel dubau
Beginner
Beginner
Posts: 3
Joined: Sun Jan 04, 2004 7:40 am

Post by noel dubau »

Thanks a lot to everyone !
I'm going to try your methods to see what is the better one ! In french we have a proverd saying "The best way is that which gives the result you hope !"
Sincerely,
Noël
User avatar
John
 Team
 Team
Posts: 5967
Joined: Sun May 19, 2002 8:23 pm
Location: Phoenix, AZ
Contact:

Post by John »

Please let us know what happens.
John
Post Reply