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: Select all
with(milonic=new menuname("AdminMenu")){
style=windows98style;
itemwidth="100";
if (!userIsAdmin) {
aI("text=Dummy;");
}
<?php
echo COM_adminMenu();
?>
}
Code: Select all
<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>
Thanks.