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

own ID for menu-Items?


Poster: Norbert
Dated: Thursday July 27 2006 - 14:04:18 BST

Hello, I need to give each menu Item my own ID.
I decided to use the 'title' for it.
Now I need a function to get the _itemRef for that ID
getItemRef(ownID)
Is there a way to do so?
What do you think of some sort of ownData item-property?
Thanks,
Norbert


Poster: Ruth
Dated: Thursday July 27 2006 - 19:29:02 BST

Hi,

I don't do functions, however there are functions for the menu that has to do with getting a menu or getting an item or getting a parent menu or parent item etc.

http://www.milonic.com/menu_methods.php

There is also a post that had to do with getting x coordinate. It's kind of long but down in it Andy gives info on getting menu and item references.

http://www.milonic.com/forum/viewtopic. ... 5424#15424

I'm sure there's a way to do it, if you can't figure it out from that info, I'll try to contact Milonic on the issue.

If you get this could you post the function here? It might be of help to someone else.

Ruth

Got it!


Poster: Norbert
Dated: Friday July 28 2006 - 11:33:01 BST

Hello, first of all many thanks to the Team Members! There are helpful and friendly answers so i want to contribute to it as well - and not to forget the menu itself looks very good. (If we decide to take it, it's a intranet-Menu of about 260 entries and it's working fine and you can make it looking the way you like!)

But now to the solution (and the reason for asking of own ID's):
It is about building a breadcrumb with milonic

Task is: we have a lot of small sites, each of them with their own (not milonic-based) navigation. We give each site (and so each page of one specific site) it's own ID. Now we want to loosely join these sites with the milonic menu. No problem so far but I want some breadcrumb. I cannot use the given solution with Url-Parameters, because of links, favourites, inter-site-Navigation and not constant id's out of milonic (when the menu changes) so I decided to use cookies and own ID's. Second thought is, that one and the same site can be found twice or more times wthin milonic.

Now we will have different ways, how to build the breadcrumb (sorry, littlebit complicated explanation 8)
<ol><li> the user clicks on the menu item and wants to get the breadcrumb from the specific way through the menu
<li> the user visits the site from a link
<li>the user navigates within the specific site
</ul>

Therefor each menu-item sets a cookie with the menu-specific ID (milonicID)
When set, the new Site confirms the cookie with its internal id.
This combination is now guilty for building the breadcrumb within the site of this internal id (on all sites with this ID).
If a site is visited via an other link, the milonicID /specificID-Pair is not guilty and the function produces a new guilty one out of the specificID.

Works really fine!

now the code:

Code:
<!-- Insert on each page -->
<script type="text/javascript">
var mm_separator = "&nbsp;==&gt;&nbsp;";
var mm_selectionSequence = "";
var mm_siteid = whateveryouwant;
mm_getSelectionSequence();

function mm_getItemWithID(ID) {
  var i = 0;
  do {
      if (_mi[i][4]==ID)
         return i;
      i++;
   } while (_mi[i]);
   return;
}

// used by each menu-item
function mm_setCookie() {
   document.cookie="mid="+_itemRef;
}
// links for the breadcrumb itself - behave just like the mm_SetCookie()
function mm_openUrl(url,dood) {
  document.cookie="mid="+dood;
  window.location.href = url;
}

// get value from cookie
function mm_getCookieValue(name) { 
  var start=document.cookie.indexOf(name + "=");    var len=start+name.length+1;
  if (( !start)&&(name!=document.cookie.substring(0,name.length))) return;
  if (start==-1) return;
  var end = document.cookie.indexOf(";",len);
  if (end==-1) end = document.cookie.length;
  return unescape(document.cookie.substring(len,end));
}

// build breadcrumb string
function mm_getSelectionSequence() {
  var i = mm_getCookieValue("mid");
  if (!i) {
   i=mm_getItemWithID(mm_siteid);
  }
  var approved=i.indexOf("#");
  if (approved!=-1) {
   bb=i.split("#");
   if (mm_siteid==bb[1])
      i=bb[0];
   else {
      i=mm_getItemWithID(mm_siteid);
      document.cookie="mid="+i+"#"+mm_siteid;
   }
  } else {
   document.cookie="mid="+i+"#"+mm_siteid;
  }
  var a1,a2;
  do {
    a1=""; a2="";
    if (_mi[i][2]) {
      a1="<a href=javascript:mm_openUrl('"+_mi[i][2]+"',"+i+")>";
      a2="</a>";
    }
    if (mm_selectionSequence == "")
      mm_selectionSequence = a1+_mi[i][1]+a2;
    else
      mm_selectionSequence = a1+_mi[i][1]+a2+mm_separator+mm_selectionSequence;
    i = getParentItemByItem(i);
  } while (!isNaN(i));
  if (mm_selectionSequence != "") {
   mm_selectionSequence =   "<i>You are here: </i>" + mm_selectionSequence;   
  }
}
</script>


now give each used style the property:

Code:
clickfunction="mm_setCookie()";


and each MenuItem the property

Code:
status=whateveryouwant;


You can now show the Breadcrumb on each Page with
Code:
<script language="javascript">document.write(mm_selectionSequence)</script>


Don't forget to give each page and each MenuItem it's own whateveryouwant-ID


Poster: Ruth
Dated: Friday July 28 2006 - 11:47:16 BST

Hi Norbert,

Thanks for the post. I have no idea what it is, but I'm sure it will help someone else.

Just to add to your information, there is a breadcrumb function for the menu, two actually. They were done by Kevin for someone here in the forum.

http://support.milonic.com/demos/

There are two there, one called Bread Crumb for use with frames and iframes, and one called Pass Item Reference which produces a text breadcrumb.

Again, thanks for posting your function. One question, what did you mean by giving each page it's own whatever id? Do you put it on the page someplace? I get the part about the item whatever id using the status but not sure on the page id.

Ruth


Poster: Norbert
Dated: Friday July 28 2006 - 12:23:18 BST

:oops: The ID is in the Code above, ok you better put it within it's own
Code:
<script type="text/javascript">
var mm_siteid = <!-- Insert ID here -->;

Actually I copied some code from them (e.g. the way to write the line).
The reason for not using the given breadcrumb-Functions are are:
<ul>
<li>I do not want to use url-parameters
<li>Links to pages without using the menu (from outside, Ad's, ...) should process a breadcrumb.
</ul>
So I use two ID's within my cookies -- the own one (to support linking from outside the menu -- and the the milonic Item number because of the fact that some page could be linked more than once in the menu and you want the actual way of clicking in the breadcrumb, not the standard way and a special task of our application: one page within one little site links to the other, and the breadcrumb should not change clicking on these links.
Hmm? okay a bit strange, but if you just try to build breadcrumbs with cookie functionality and tomorrow you go to your pages again unsing favourites, the old cookie causes wrong breadcrumb?. [/code]


Poster: Ruth
Dated: Friday July 28 2006 - 12:38:13 BST

Hi,

Thanks for the explanation. Now that you point it out I see the id you mentioned. Maybe I should edit your post and put in a //CHANGE whateveryouwant TO YOUR PAGE ID HERE next to that var mm_siteid = whateveryouwant;

What do you think?


I was sure the one from Milonic wouldn't do what you wanted, but since this is to do with breadcrumbs I wanted to post the link since it might serve for someone searching about breadcrumbs.

Ruth