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

Is it possible to use the treemenu and the API together?


Poster: rjmjr9
Dated: Saturday December 16 2006 - 19:06:58 GMT

I am trying to change the background image on an item when the user clicks. This works. But when a user clicks on another item, the first item should change back to its original background.

I have tried several things, including pagematch/url. I can't use pagematch/url because it wants to load a page and the page is already loaded.

I can do what I want with mm_editItemByItemRef coded in a LONF javascript routine, but then the tree menu parent closes when it executes the script. Are there any workarounds? Or is there an additional tree menu function I need. I have tried several of the open functions without success. Also, any function that is not defined in the treemenu that uses the menu name doesn't work, at least for me.

Any help or insight would be greatly appreciated.

Thanks.


Poster: Ruth
Dated: Sunday December 17 2006 - 19:14:20 GMT

Hi,

DISCLAIMER: I am not well versed in this, it is something I've tried over time and have had problems with it, however this time it seems to work like a charm :)

So, yes it seems to work with the treemenu.js module.

To use it:

1. you would put the call for the module BEFORE the call for the data file. It needs to be 'running' so it can read the data file. If you put it after then the data file is already built before the menueditapi is up and it has nothing to work on because what it would have changed is already built.

2. put the mm_s after the drawMenus(); in the data file, I don't know that it needs a semi-colon after the drawMenus, but I always make sure it's there.

There are some things I noticed and I'm not sure why they work like this. I remember that counting is from 0 up, so usually if something says item 3, it is your actual 'visual' item 4. I tested each mm separately to make sure each worked and found that
Code:
mm_deleteItem('mainTreeMenu',3) // Removes third item in Main Menu
actually did remove the 'visible' item 3, i.e. the 3rd item in the menu, News. But the other mm_s seem to go back to the counting starting with 0, so inserting an item at number 2

Code:
mm_insertItem('mainTreeMenu',2,'text=New Item;url=test.html;offcolor=yellow;offbgcolor=darkblue;') // Inserts a new item at position 2 in Main Menu
actually inserts the item in the 'visual' item 3 spot, that is you have Milonic, Home, then the new item so it seems to insert the item AFTER the second visual item.

The same holds true for the
Code:
mm_editItem('mainTreeMenu',4,'text=Changed Item;url=index.php') // Modifies the details of menu item 4 in Main Menu
where the 'visual' item 4 is Finance but the item 4 [counting from 0 to 4] is Sports, and it is Sports which gets changed to have the url in it.

I hope that made sense. I just wanted to make sure you keep the numbers in mind so you change the items you want and add an item where you want and delete the actual item you want :) And, finally, maybe they all work exactly like they are supposed to work! JS is not my field. :?

Ruth


Poster: rjmjr9
Dated: Sunday December 17 2006 - 19:54:28 GMT

Ruth,

First, thank you for the reply.

Second, a couple questions:

1) regarding #1) Do you mean the file order needs to be:

Code:
<script type="text/javascript" src="Scripts/milonic_src.js"></script>
<script type="text/javascript" src="Scripts/mmenudom.js"></script>
<script type="text/javascript" src="Scripts/treemenu.js"></script>
<script type="text/javascript" src="Scripts/mm_menueditapi.js"></script>

<script type="text/javascript" src="Scripts/menu_data"></script>
<script type="text/javascript" src="Scripts/tree_data"></script>

2) What is mm_s? Is this the call to the mm_menuapi routines? And they go into the tree menu data file or do they go into a custom function called bt clickfunction that includes a drawMenu;?

I am just trying to understand what I am going to do before I do it. I appreciate what have shown me.


Poster: Ruth
Dated: Sunday December 17 2006 - 20:57:33 GMT

Hi,

Well, I found that info as to where to put the call for the module in another post so I am just using that as my information on where to put the call for it. It seems logical since it will read the mm_s [see below] and make the changes so it would have to be 'functioning' before the menu is built so it could read the stuff it is supposed to do. My terms are probably not accurate, they are just the way I visualize things. I tested it to see an dif you put it after the collapse_data.js file you get an object expected error.

Code:
<SCRIPT language=JavaScript src="milonic_src.js" type=text/javascript></SCRIPT>   
<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="mm_menueditapi.js"></script>
<SCRIPT language=JavaScript src="collapse_data.js" type=text/javascript></SCRIPT>
      
<SCRIPT language=JavaScript src="treemenu.js" type=text/javascript></SCRIPT>



As to the 'mm_s' I just used that as shorthand for the things you would insert delete change since they are listed as mm_deleteItem, mm_insertItem, mm_editItem, and I didn't want to write them out.


They have to be after the drawMenus(); since the menu has to be built before they will work and the menueditapi.js module works on them so it has to be available before the menu data file on which changes will be made. Hope that made sense.

Use the original download of the treemenu, the original collapse_data.js file that you got when you downloaded it, and add this after the drawMenus and then look at the treemenu. I put the 'original' information into the items. Of course the mm_delete one just deletes an item so you won't see it in the menu.

Code:
mm_deleteItem('mainTreeMenu',3) // Removes third item in Main Menu - this is the News Item
mm_insertItem('mainTreeMenu',2,'text=New Item - originally News-but that was deleted by the previous mm_delete item call in the data file;url=test.html;offcolor=yellow;offbgcolor=darkblue;') // Inserts a new item at position 2 in Main Menu
mm_editItem('mainTreeMenu',4,'text=Changed Item - originally Sports. Now has a url put in by the menueditapi;url=index.php;offcolor=red;offbgcolor=yellow;') // Modifies the details of menu item 4 in Main Menu


Ruth


Poster: rjmjr9
Dated: Monday December 18 2006 - 1:13:44 GMT

Thanks Ruth. Thats just what I need.