I have a huge project that has multiple parts. I am trying to figure out the best way to build my menus. I know, put it in the components menu. That would be great, but the customer wants their own drop down menu and with the number of items on the menu I'm building, it is probably a good idea. So when I build the package and try to install it, my menu doesn't load the way that I had hoped. As far as I can tell the primary top menu was never even created. My ultimate goal is to have the menu I create fall between the site menu and components menu.
I've modified my transport file:
$modx->log(modX::LOG_LEVEL_INFO,'Packaging in menu...');
$menus = include $sources['data'].'transport.menu.php';
if (empty($menus)) $modx->log(modX::LOG_LEVEL_ERROR,'Could not package in menu.');
foreach ($menus as $menu) {
$vehicle= $builder->createVehicle($menu,array (
xPDOTransport::PRESERVE_KEYS => true,
xPDOTransport::UPDATE_OBJECT => true,
xPDOTransport::UNIQUE_KEY => 'text',
xPDOTransport::RELATED_OBJECTS => true,
xPDOTransport::RELATED_OBJECT_ATTRIBUTES => array (
'Action' => array (
xPDOTransport::PRESERVE_KEYS => false,
xPDOTransport::UPDATE_OBJECT => true,
xPDOTransport::UNIQUE_KEY => array ('namespace','controller'),
),
),
));
}
My menu file looks like:
// top level menu
$action=$modx->newObject('modAction');
$action->fromArray(array(
'id' => 1,
'namespace' => 'addon',
'parent' => 0,
'controller' => 'index',
'haslayout' => true,
'lang_topics' => 'addon:default',
'assets' => '',
),'',true,true);
$menu=$modx->newObject('modMenu');
$menu->fromArray(array(
'text' => 'addon',
'parent' => 0,
'description' => 'addon.desc',
'icon' => 'images/icons/plugin.gif',
'menuindex' => 0,
'params' => '',
'handler' => '',
),'',true,true);
$menu->addOne($action);
$menus[] = $menu;
unset($action);
unset($menu);
// first menu item
$action=$modx->newObject('modAction');
$action->fromArray(array(
'id' => 1,
'namespace' => 'addon',
'parent' => 0,
'controller' => 'menu1',
'haslayout' => true,
'lang_topics' => 'addon:default',
'assets' => '',
),'',true,true);
$menu=$modx->newObject('modMenu');
$menu->fromArray(array(
'text' => 'addon.menu1.manager',
'parent' => 'addon',
'description' => 'addon.menu1.manager.desc',
'icon' => 'images/icons/plugin.gif',
'menuindex' => 0,
'params' => '',
'handler' => '',
),'',true,true);
$menu->addOne($action);
$menus[] = $menu;
unset($action);
unset($menu);
// second menu item
$action=$modx->newObject('modAction');
$action->fromArray(array(
'id' => 1,
'namespace' => 'addon',
'parent' => 0,
'controller' => 'menu2',
'haslayout' => true,
'lang_topics' => 'addon:default',
'assets' => '',
),'',true,true);
$menu=$modx->newObject('modMenu');
$menu->fromArray(array(
'text' => 'addon.menu2.manager',
'parent' => 'addon',
'description' => 'addon.menu2.manager.desc',
'icon' => 'images/icons/plugin.gif',
'menuindex' => 0,
'params' => '',
'handler' => '',
),'',true,true);
$menu->addOne($action);
$menus[] = $menu;
unset($action);
unset($menu);
// etc...
return $menus;
So, before I spend any more hours on this that I don't have, can this even be done using the package builder, or does this have to be done by hand?