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?
Deleting all items from menu
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. http://milonic.com/forum/viewtopic.php?t=3632qperkins wrote:if someone could just help me identify the array I would need to zero, I could do it myself.
Ruth
I have what you need....I think:)
Hi,
Check out http://www.slotracinglemans.com. 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:
In your code you can then do the following:
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
Check out http://www.slotracinglemans.com. 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:
Code: Select all
CREATE TABLE menu (
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)
) TYPE=MyISAM;
Code: Select all
$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 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
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.
Cheers,
Kevin
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.
Cheers,
Kevin