脚本宝典收集整理的这篇文章主要介绍了php – 以编程方式在Joomla中创建菜单项,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
//add the article to a menu ITem $menuTable = JTable::getInstance('Menu','JTable',array()); $menuData = array( 'menutyPE' => 'client-pages','title' => $data[name],'type' => 'component','component_id' => 22,'link' => 'index.PHP?option=com_content&view=article&id='.$resultID,'language' => '*','published' => 1,'parent_id' => '1','level' => 1,); // Bind data if (!$menuTable->bind($menuData)) { $this->setError($menuTable->getError()); return false; } // Check the data. if (!$menuTable->check()) { $this->setError($menuTable->getError()); return false; } // Store the data. if (!$menuTable->store()) { $this->setError($menuTable->getError()); return false; }
错误似乎与设置parent_id和级别有关.在调试库/ joomla / database / tablenested.PHP时,将parent_id和level设置为0.这会在我的管理员页面上导致以下错误:
$table->setLocation($parent_id,'last-child');
我还认为你需要重建路径:
// Rebuild the tree path. if (!$table->rebuildPath($table->id)) { $this->setError($table->getError()); return false; }
如果它仍然不起作用,试着找出你不做的MenusModelItem::save.
以上是脚本宝典为你收集整理的php – 以编程方式在Joomla中创建菜单项全部内容,希望文章能够帮你解决php – 以编程方式在Joomla中创建菜单项所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。