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

Empty Submenu generating an error


Poster: blaine
Dated: Saturday April 10 2004 - 19:32:43 BST

I have a sub-menu that will only be displayed if the user is an admin and it is generated dynamically from PHP. This is all working in testing ok.

If the user does not have any admin access, then the menuitem with it's sub-menu should not be displayed. I am getting a JS error when the the main menu is generated. It correctly does not show the sub-menu and main menu title for the submenu but is complaining because I have a menu defined in the menu_data.php that has no menu items -- even though it is not being asked to be used.

The error I get is:
- Error: '_m[...].7' is null or not an object

To solve it, I have had to include a dummy menu item when there would not be any menu items at all to show -- again even though the menu would not be displayed.

My Menu Definition in menu_data is:
Code:
with(milonic=new menuname("AdminMenu")){
    style=windows98style;
    itemwidth="100";
    if (!userIsAdmin) {
        aI("text=Dummy;");
    }
    <?php
        echo COM_adminMenu();
    ?>
}


The code for the menu is as follows:
Code:
  <script>
    with(milonic=new menuname("Site Sections")) {
        style=menuStyle;
        position="relative"
        top=0;
        left=0;
        alwaysvisible=1;
        orientation="vertical";
       aI("text=Home ;url=;status=Testing Milonic Menu;");
       aI("text=General News (0/0);url=http:www.mysite.com/index.php?topic=General;status=Testing Milonic Menu;");
       aI("text=First Subject;url=http://www.mysite.com/index.php?topic=subject1;status=Testing Milonic Menu;");
       aI("text=StaticPages;showmenu=StaticPages;");
       if (userIsAdmin) {
           aI("text=Admin Menu;showmenu=AdminMenu;");
       }
    }
    drawMenus();
  </script>


Can you suggest a better alternative or something I am doing wrong.

Thanks.