We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 36613
    • 328 Posts
    I crete a new plugin, the plugin work but the build of menu fail.
    In the transport.menu.php create this url:
    /a4vdbm/?a=11&namespace=filesmanager
    but the correct url is:
    /a4vdbm/?a=index&namespace=filesmanager
    My transport.menu.php is:

    <?php
    $action = $modx->newObject('modAction');
    $action->fromArray(array(
        'id' => 1,
        'namespace' => 'filesmanager',
        'parent' => 0,
        'controller' => 'index',
        'haslayout' => true,
        'lang_topics' => 'filesmanager:default',
        'assets' => '',
            ), '', true, true);
    
    $menu = $modx->newObject('modMenu');
    $menu->fromArray(array(
        'text' => 'filesmanager',
        'parent' => 'components',
        'action' => 'index',
        'description' => 'filesmanager.filesmanager_desc',
        'icon' => 'images/icons/plugin.gif',
        'menuindex' => 0,
        'params' => '',
        'handler' => '',
        'namespace' => 'filesmanager', 
            ), '', true, true);
    $menu->addOne($action);
    
    
    return $menu;
    

    Maybe this is the problem:

    https://github.com/modxcms/revolution/issues/12867
      • 3749
      • 24,544 Posts
      Yes, you're mixing old and new menu methods as suggested in that link.

      Menus no longer have an action object. Now they just find the action file based on their namespace's core path + action string.

      Try just this:

      $menu = $modx->newObject('modMenu');
      $menu->fromArray(array(
          'text' => 'filesmanager',
          'parent' => 'components',
          'action' => 'index',
          'description' => 'filesmanager.filesmanager_desc',
          'icon' => 'images/icons/plugin.gif',
          'menuindex' => 0,
          'params' => '',
          'handler' => '',
          'namespace' => 'filesmanager', 
              ), '', true, true);
      
      return $menu;


      You may have to manually remove the action record your code created in the modx_actions table.

      FYI, MyComponent will create the transport file automatically for you based on the Menu items in your project.
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting