Milonic provide full featured pull down web menus for some of the worlds largest companies
click here to see what it can do for you

Download Milonic DHTML Menu
Buy Milonic DHTML Menu

Back To Start Of Archive
Taken From The Forum: Help & Support for DHTML Menu Version 5+
Forum Topic: Click to view post
Last Updated: Saturday July 14 2012 - 06:07:53

Relative paths and milonic


Poster: yes2work1
Dated: Wednesday September 27 2006 - 15:05:09 BST

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 __at__ yes2work.org.uk


Poster: Andy
Dated: Wednesday September 27 2006 - 23:34:59 BST

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://www.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


Poster: yes2work1
Dated: Friday September 29 2006 - 11:35:00 BST

Hi Andy,

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

Cheers


Poster: yes2work1
Dated: Friday September 29 2006 - 13:46:53 BST

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


Poster: Ruth
Dated: Friday September 29 2006 - 15:01:52 BST

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:
url=http://www.whatever.com/help/html/page.htm
If I didn't understand what you really wanted please post back :)

Ruth


Poster: yes2work1
Dated: Friday September 29 2006 - 15:23:23 BST

Thanks.

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

Cheers


Poster: Ruth
Dated: Friday September 29 2006 - 15:38:51 BST

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:
<script type="text/javascript" src="../../milonic_src.js"></script>   
<a class=milonic href="http://www.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


Poster: yes2work1
Dated: Friday September 29 2006 - 16:10:26 BST

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


Poster: Ruth
Dated: Friday September 29 2006 - 20:37:47 BST

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


Poster: kevin3442
Dated: Monday October 2 2006 - 4:26:39 BST

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:
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:
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:
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:
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

Relative paths and milonic


Poster: yes2work1
Dated: Monday October 2 2006 - 10:10:46 BST

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


Poster: John
Dated: Monday October 2 2006 - 15:47:29 BST

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.