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

Deleting all items from menu

Poster: qperkins
Dated: Sunday February 13 2005 - 4:41:57 GMT

I need to dynamically add and delete from the menus. The way I would like to do this, is to call a script that empties a menu and then re-builds it based on user supplied info.

I can add and edit at will with the mm_changeItemProperty that Andy provided. It also allows for a remove a selected entry, but I need to erase an entire menu to rebuild. I would like either a script that would erase all of the entries in a selected menu or if someone could just help me identify the array I would need to zero, I could do it myself.

Can anyone please help me?

Poster: Ruth
Dated: Sunday February 13 2005 - 7:43:16 GMT

qperkins wrote:
if someone could just help me identify the array I would need to zero, I could do it myself.

I don't know if this will give any kind of information that will help, but it has things about how to get a menu, positioning the menu, and talks later about how you find an item. It talks about how menu items are numbered 0 to xxxx and they are listed as el# something like that. It may have nothing related to what you are asking, since I don't really know anything about the internals of the menu. But it does talk about how items are identified. Sorry, I can't be of more help but it is really beyond my level of knowledge.


I have what you need....I think:)

Poster: willemk
Dated: Sunday February 13 2005 - 11:23:18 GMT


Check out he meu items under the submenu members are dynamically generated based on the user logged in.
If you are familiar with database driven websites it shouldn´t be that big of problem for you.

I use MYSQL and PHP. You can create a simple table like this for instance:
  mid smallint(6) NOT NULL auto_increment,
  text varchar(40) NOT NULL default '',
  url varchar(40) NOT NULL default '',
  status char(3) NOT NULL default '',
  PRIMARY KEY  (mid),
  KEY text (text,url)

In your code you can then do the following:
$query = mysql_query("select * from menu where status = 'on'");
while($result = mysql_fetch_array($query)) {
        $menuitems .= "aI(\"text=$result[text];url=$result[url];\");\n";

The query only selects those rows you have given the value "on".
The while loop loops through the records and generates the meu items.
$menuitems can now be added to your existing menu whereever you want it to be.
Note: See the backslash and the n ( \n ) after each menu item being fetched. This makes it easier to view the source when you are testing.

A simple administrator page which lets you insert delete and change the menu items in the table and you are there.

Hopes this helps

Poster: Ruth
Dated: Monday February 14 2005 - 17:19:00 GMT

Thanks for the information on the mysql/php based menu and deleting and rebuilding, wellemk. That's a great resource for any who use that kind of setup. We get queries on mysql/php, we appreciate the input!


Poster: kevin3442
Dated: Monday February 21 2005 - 23:30:59 GMT

Just reviewing some posts after being out of town last week...

Anyone interested in dynamically adding, modifying, or deleting menu items after the menus have been rendered on a page should review this topic, which discusses a recently added api for editing menus.