Relative paths and milonic

Having problems with DHTML Menu? There is usually somebody here who knows the answer.
Post Reply
yes2work1
Beginner
Beginner
Posts: 8
Joined: Wed Sep 27, 2006 3:00 pm

Relative paths and milonic

Post by yes2work1 »

I’ve just configured Milonic for use on our intranet site and am having some problems in getting the scripts to work. The scripts work fine as long as the page on which the script block is placed is in the same directory as the .js (JavaScript) files. However if try to use Milonic on a page which is in a subdirectory then all I see is a link to the milonic site.

My question is simple, what is the syntax for calling milonic from a page which is in a subdirectory?

Regards,





Neall McLaren
ICT Assistant


Yes2work Ltd.
The Acorn Centre
51 High Street
Grimethorpe
Barnsley
S 72 7BB


Website: http://www.yes2work.org.uk
Email: nmclaren@yes2work.org.uk
User avatar
Andy
Milonic
Milonic
Posts: 3308
Joined: Sun May 19, 2002 8:23 pm
Location: Menu Developer
Contact:

Post by Andy »

Hi,

You should always use the full path to the menu files just in case you want to move into a sub directory.

You can either declare the domain name as in: http://milonic.com/milonic_src.js or remove the domain name and replace with (for example) /milonic_src.js - note that the filename is always prefeixed with a / to denote the main (root) directory.

Hope this helps,
Andy
yes2work1
Beginner
Beginner
Posts: 8
Joined: Wed Sep 27, 2006 3:00 pm

Post by yes2work1 »

Hi Andy,

Putting the full path worked although it doesn’t look too elegant it'll do nicely

Cheers
yes2work1
Beginner
Beginner
Posts: 8
Joined: Wed Sep 27, 2006 3:00 pm

Post by yes2work1 »

Hi

What is the correct syntax to use when specifying the URL’s for the different menu items within the menu_data.js file?

Cheers
User avatar
Ruth
 Team
 Team
Posts: 8763
Joined: Thu May 15, 2003 5:02 am
Location: Yucaipa, CA
Contact:

Post by Ruth »

Hi,

Not sure I understand what you're asking, but if you mean how do you do the 'links' in the aI url section, you'd do the same as you would for an a href= but without the quotes. For example:

Code: Select all

url=http://www.whatever.com/help/html/page.htm
If I didn't understand what you really wanted please post back :)

Ruth
yes2work1
Beginner
Beginner
Posts: 8
Joined: Wed Sep 27, 2006 3:00 pm

Post by yes2work1 »

Thanks.

That's fine, but is there no way of doing this using relative paths?

Cheers
Last edited by yes2work1 on Fri Sep 29, 2006 3:39 pm, edited 1 time in total.
User avatar
Ruth
 Team
 Team
Posts: 8763
Joined: Thu May 15, 2003 5:02 am
Location: Yucaipa, CA
Contact:

Post by Ruth »

Hi,

Well, I would guess so, but I always use full paths. If you unzip all the files in the menu download and then go to the extras folder and listbased folder, for example, and open the index.htm page the code to call the menu files is

Code: Select all

<script type="text/javascript" src="../../milonic_src.js"></script>	
<a class=milonic href="https://milonic.com/">JavaScript Menu, DHTML Menu Powered By Milonic</a>
<script type="text/javascript">
if(ns4)_d.write("<scr"+"ipt type=text/javascript src=../../mmenuns4.js><\/scr"+"ipt>");		
  else _d.write("<scr"+"ipt type=text/javascript src=../../mmenudom.js><\/scr"+"ipt>"); 
</script>
<script type="text/javascript" src="listmenus.js"></script>
Isn't that a relative path, referring back to the main folder in which the menu program files are located? So, the index page for the listmenu is in mainFolder/extras/listbased/ and the program files are in the main folder. As you can tell paths are not my thing! It has just always been easier for me to use full path and I always know the files are found :)

Ruth
yes2work1
Beginner
Beginner
Posts: 8
Joined: Wed Sep 27, 2006 3:00 pm

Post by yes2work1 »

Thanks for the replay but I was actually hoping that I could use relative paths within the menu_data.js file so that all the menu item URL’s are relative to the site root - I’ve tried using ./foldername/file.htm and ../foldername/file.htm but this doesn't appear to be working on some of my pages.

In short I want to avoid hard coding the absolute path to a file in the menus as I see this as messy coding :-(

Cheers
User avatar
Ruth
 Team
 Team
Posts: 8763
Joined: Thu May 15, 2003 5:02 am
Location: Yucaipa, CA
Contact:

Post by Ruth »

Hi,


I'm going to post for someone else to help you, as I said paths are the bain of my existence so I use full or absolute.


Hopefully someone can answer your question.

Ruth
User avatar
kevin3442
Milonic God
Milonic God
Posts: 2460
Joined: Sat Sep 07, 2002 12:09 am
Location: Lincoln, NE
Contact:

Post by kevin3442 »

yes2work1 wrote:Thanks for the replay but I was actually hoping that I could use relative paths within the menu_data.js file so that all the menu item URL’s are relative to the site root - I’ve tried using ./foldername/file.htm and ../foldername/file.htm but this doesn't appear to be working on some of my pages.

In short I want to avoid hard coding the absolute path to a file in the menus as I see this as messy coding :-(

Cheers
Hi Neall,

Yes, you can use relative paths. But the paths you've given as examples are relative to the currently-displayed page, not relative to the site's root. E.g., let's say you're currently looking at:

Code: Select all

http://www.yourdomain.com/products/widget.htm
A single "." at the beginning of the path refers to the folder that the currently-displayed page came from. So, in your example, ./foldername/file.htm, tells the server to get:

Code: Select all

http://www.yourdomain.com/products/foldername/file.htm
A ".." at the beginning of the path refers to the parent directory of the one containing the currently-displayed page. So, keeping in mind our assumed starting point of widget.htm, your example of ../foldername/file.htm, tells the server to get:

Code: Select all

http://www.yourdomain.com/foldername/file.htm
You can use these approaches -- "." and ".." -- but you must keep in mind that they are relative to the location of the currently-displayed page. Of course, that can have unexpected results if your site is arranged into several folders. Such a path used from one page can resolve to a completely different location as the same exact relative path used in a different page. The problem is clear if you hope to use the same menu code on each page.

If you want to use paths relative to the site's root, then start each url with a "/" (no dots) to refer to the root directory. This would be independent of the location of the current page.

Code: Select all

aI("text=Item Text;url=/foldername/subfoldername/file.htm;");
Give that a try and see if it gets you where you need to be (pun intended).

Hope that helps,

Kevin
yes2work1
Beginner
Beginner
Posts: 8
Joined: Wed Sep 27, 2006 3:00 pm

Relative paths and milonic

Post by yes2work1 »

Hi Kevin,

I’ve tried what you suggested i.e. using / as opposed to ../ or ./ and this isn’t working as / takes me to the IIS Server root (this is not the same as the root directory of the website which uses the miloic menu).

I’ve tried to solve the problem by using HTML Base tags on each of the pages but this doesn’t help matters as the Base tags only work on HTML and not JavaScript.

I’ve considered reconfiguring IIS but am unsure if it is possible to change the relative path for the entire site at server level.

Any further assistance would be great, as I’m reluctant to hard-c0ode absolute URL’s into the site.

Cheers

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

Post by John »

In the URL you left in your first message, I do not find any calls to, or use of, the Milonic menu. Kevin's explanation was, of course, right on, so we'll need to see the site to figure out what's wrong.
John
Post Reply