Insert Multiple Rows in table with lft and rgt columns

For Joomla! 3.x Coding related discussions, you could also use: http://groups.google.com/group/joomla-dev-general

Moderator: ooffick

Forum rules
Locked
jonBuckner1
Joomla! Explorer
Joomla! Explorer
Posts: 428
Joined: Mon Nov 12, 2012 9:08 am

Insert Multiple Rows in table with lft and rgt columns

Post by jonBuckner1 » Thu Jan 28, 2016 6:34 am

Hi folks

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;
}

jonBuckner1
Joomla! Explorer
Joomla! Explorer
Posts: 428
Joined: Mon Nov 12, 2012 9:08 am

Re: Insert Multiple Rows in table with lft and rgt columns

Post by jonBuckner1 » Wed Feb 03, 2016 2:53 pm

Hi

Well, I have the answer...

I have added it to a post that predates this one
http://forum.joomla.org/viewtopic.php?f=727&t=902602


Locked

Return to “Joomla! 3.x Coding”