I have been able to create a menu item dynamically:
http://forum.joomla.org/viewtopic.php?f=727&t=902602
However, ideally, I would like to add multiple menu items simultaneously.
I have read these cool posts:
https://docs.joomla.org/Using_nested_sets
https://www.23creative.com.au/latest-ne ... o-database
https://docs.joomla.org/Using_nested_sets
I am too ignorant of all things clever to know how to do it.
Any gurus willing to show me the way?
Thanks
Jon
Code to create ONE entry:
Code: Select all
$menuTable = JTableNested::getInstance('Menu');
// which menu you want to add to -
$menutype = 'thisismymenusname';
// this is heading menu item but what data you have and require will vary per case - just look at an appropriate row in yr menu table
$menuData = array(
'menutype' => $menutype,
'title' => $table->alias,
'alias' => $table->alias,
'path' => $table->alias,
'type' => 'heading',
'component_id' => 0,
'language' => '*',
'published' => 1,
);
$parent_id = 1;
$menuTable->setLocation($parent_id, 'last-child');
// save is the shortcut method for bind, check and store
if (!$menuTable->save($menuData))
{
$this->setError($menuTable->getError());
return false;
}