How do you begin?

Having problems with DHTML Menu? There is usually somebody here who knows the answer.
User avatar
Hergio
Milonic God
Milonic God
Posts: 1123
Joined: Wed Jun 12, 2002 7:46 pm
Location: Rochester, NY

Post by Hergio »

May I butt in here, you have all the source files in a directory together, thats great. But you are not referencing them from the page correctly. Heres what your page says...
<script language=JavaScript src="/images/menu/milonic/milonic_src.js" type=text/javascript></script>
<script language=JavaScript src="/images/menu/milonic/menu_data.js" type=text/javascript></script>
When your files are actually located at /HortonRealty/images/menu/milonic/ ...so change that first. THen your milonic_src is still wrong, it should be EXACTLY
scriptpath = "/HortonRealty/images/menu/milonic/";
And John, just to clarify, but now I am second guessing myself, but because shes starting the script path off with a / that means its starting from the root (.com) so she needs the HortonRealty/, right? Your on the right track surfergirl, we'll get you there. ;)
Dave Hergert
Software Engineer
"Helping to make the menu better, one :?: at a time."
Surfergirl
Super Advanced
Super Advanced
Posts: 77
Joined: Fri Jun 27, 2003 5:38 pm
Location: TCI

Post by Surfergirl »

:D It worked!

I don't believe it. You know why ? When I had the files working in the main directory, then moved them, DW made the change to /images/menu/milonic/etc.js I figured that it was correct. Never in a million years would I have put /HortonRealty/ in front of that.

So, are you saying that if I put the menu on a different page that is inside a subfolder like /HortonRealty/Listings/Residential/index.htm I keep the path to the script on that page /HortonRealty/images/menu/milonic/etc.js ?
User avatar
John
 Team
 Team
Posts: 5967
Joined: Sun May 19, 2002 8:23 pm
Location: Phoenix, AZ
Contact:

Post by John »

Yes, more gray hair.

I set up a dup of your site on my server and can't get it working here, either (but the page is loading with no JS errors!).

Need to do some more digging.
John
User avatar
Hergio
Milonic God
Milonic God
Posts: 1123
Joined: Wed Jun 12, 2002 7:46 pm
Location: Rochester, NY

Post by Hergio »

Yes surfer girl , thats exactly it. That path will work from anywhere because you are always starting from the root (hence the / in the beginning). To make my life easier, I tuck all my includes away in a nice well kept directory and then I create a virtual directory to them (called inc), so ANYWHERE on my site I can reference all my includes with a simple little oneliner like... <script src="/inc/menu_data.js"></script> even though my menu_data is like 5 levels down. ;) :) works for me!
Dave Hergert
Software Engineer
"Helping to make the menu better, one :?: at a time."
User avatar
John
 Team
 Team
Posts: 5967
Joined: Sun May 19, 2002 8:23 pm
Location: Phoenix, AZ
Contact:

Post by John »

Yes, exactly correct, Dave. It's been a zoo here already this week with the first day of classes yesterday, on top of which we moved folks into our first ever for this campus dorms on Saturday.

So, the ol' crossed eyes missed the root of the page. But then, it did take a while to get her to remove the dang // from in front of scriptpath :!: ;)
John
Surfergirl
Super Advanced
Super Advanced
Posts: 77
Joined: Fri Jun 27, 2003 5:38 pm
Location: TCI

Post by Surfergirl »

Thanks Hergio and Maz and big kudos to John - Someday I'll be such a wiz I can return the favor.

I'm not totally understanding how it works - it's not following the same logic for file structure that I learned way back when ../../file.htm

And throw in another loop when you say 'virtual directory' is only 1 directory down when the file is really 5 directories down... can you explain it in layman terms, web design 101? Reason is I'm going to have to move the whole thing again....scary eh?
Surfergirl
Super Advanced
Super Advanced
Posts: 77
Joined: Fri Jun 27, 2003 5:38 pm
Location: TCI

Post by Surfergirl »

yeah but the script came with the // already installed !
User avatar
John
 Team
 Team
Posts: 5967
Joined: Sun May 19, 2002 8:23 pm
Location: Phoenix, AZ
Contact:

Post by John »

Surfergirl wrote:yeah but the script came with the // already installed !
Yep, because the new file didn't have anything filled in for scriptpath, and also it is possible that, depending on the setup, a value might not be needed there. In your case it was needed, so that line had to be un-commented (i.e., remove the //). Commented lines (//) are ignored entirely, so even earlier when we (finally) had the path correct, the line was ignored because of the //.
John
User avatar
John
 Team
 Team
Posts: 5967
Joined: Sun May 19, 2002 8:23 pm
Location: Phoenix, AZ
Contact:

Post by John »

Surfergirl wrote:And throw in another loop when you say 'virtual directory' is only 1 directory down when the file is really 5 directories down... can you explain it in layman terms, web design 101? Reason is I'm going to have to move the whole thing again....scary eh?
Dave's explanation was good and right on. "1 directory down" is the way it appears, obviously not the way it really is. It's called server relative addressing (the leading / and the path we set up tells us that). As long as you don't change that structure you can add anything else you like with no problems.

Unlike this, if you code using ../../images/a.gif, and then move that page to a different level, you've got a problem, since the above example backs up 2 directories from its current level. Wherever it is it's going to back up the same amount. At some point it won't find what it's looking for. In addition, you've got to code differently depending on the level the page is on - ../images, or ../../../images, etc. Royal pain.
John
Surfergirl
Super Advanced
Super Advanced
Posts: 77
Joined: Fri Jun 27, 2003 5:38 pm
Location: TCI

Post by Surfergirl »

So a virtual directory has a leading / in front of the path from the root level, that's vd? Thanks again John, sorry to mess up your hair
User avatar
John
 Team
 Team
Posts: 5967
Joined: Sun May 19, 2002 8:23 pm
Location: Phoenix, AZ
Contact:

Post by John »

By George, I think she's got it...
John
User avatar
Hergio
Milonic God
Milonic God
Posts: 1123
Joined: Wed Jun 12, 2002 7:46 pm
Location: Rochester, NY

Post by Hergio »

I dont want to get too technical with ya, but basically starting a path with a / just means to begin at the root. And generally virtual directories are in the root to make things easier, thats their whole point. SO you usually refer to virtual directories like /virtualDir/......

A virtual directory is basically just a 'made-up' mapping (usually easier) onto a real directory. So I could have my menu js files in ...com/includes/milonic/v5/menu/sources/ directory, but thats just a mouth full so I can tell the server, 'hey, whenever I say "/menu/" I want you to think "/includes/milonic/v5/menu/sources/", got it server?' This just makes life alot easier, and technically there is no /menu/ directory in the root, but virtually there is because the server will swap in the longer mapping. And another great thing about them is, the files you want the virtual directory to point to dont have to be inside the wwwroot directory, they could be in your My Documents folder for example. They give you the ablility to publish things to the web without having to move them over to the wwwroot directory. (BTW, wwwroot is the default directory on MS servers for the root of the web directory)

And the slash before a directory, as I said tells the server to start looking for these files beginning from the root...no matter where the page may exist in the directory structure. Like John said, the ../../ gets crazy because its all relative. You move the file that says ../../ to another directory, and ../../ could mean a totally different thing. /menu/ will always means the same thing no matter what directory I say it from.

Whew, class dismissed! :lol:

ADDENDUM - Got it John! :D
Last edited by Hergio on Wed Aug 27, 2003 3:52 am, edited 1 time in total.
Dave Hergert
Software Engineer
"Helping to make the menu better, one :?: at a time."
User avatar
John
 Team
 Team
Posts: 5967
Joined: Sun May 19, 2002 8:23 pm
Location: Phoenix, AZ
Contact:

Post by John »

Actually I wasn't talking about a 'real' virtual directory (every one of my Student Affairs directories is such - tons of 'em), but was just using the term in the context of that discussion.
John
User avatar
fredlongworthhighschool
Mega Advanced
Mega Advanced
Posts: 362
Joined: Fri Jun 27, 2003 11:34 am
Location: Manchester, England.
Contact:

Post by fredlongworthhighschool »

I think the best way to start is just with your files in one folder. Have your home page and the JS files all together, and the little down and right arrows.

Get your site working and then start to organise things into folders. All you have to do is add one "/" or miss one out or get confused with ".." and you're stumped.
Andy Davis
Web Designer & Smartboard Manager

Fred Longworth High School, Manchester, England.
Surfergirl
Super Advanced
Super Advanced
Posts: 77
Joined: Fri Jun 27, 2003 5:38 pm
Location: TCI

Post by Surfergirl »

Thanks Dave - that was great info, I have seen you explain exactly that before in the forum - its starting to sink in - educators always repeat the explanation 3 different ways to make sure even the slowest learners finally catch on....
User avatar
Maz
Milonic God
Milonic God
Posts: 1717
Joined: Fri Jun 06, 2003 11:39 pm
Location: San Francisco
Contact:

Post by Maz »

Hergio wrote:To make my life easier, I tuck all my includes away in a nice well kept directory and then I create a virtual directory to them (called inc), so ANYWHERE on my site I can reference all my includes with a simple little oneliner like... <script src="/inc/menu_data.js"></script> even though my menu_data is like 5 levels down. ;) :) works for me!
I'm learning the zen of php through the transition of volunteers, so this must be the equivalent to index.php. I must check into this. Here is the scenerio, my site got launched and the under development page came down, couldn't figure out how, instead I set up .htaccess, then my links didn't work without including index.php, now when the site is launched I'll have to change all the links back. I must locate the original script.

Thanks for the tips,
maz
Post Reply