We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 39742
    • 29 Posts
    Hello.

    I'm developing an extra following the doodles tutorial.
    Has I understand the Actions are routed to the a class named by concatenating the Action name and "ManagerController" located in the file (ActionName).class.php in the Core_Path of the namespace.

    I can also pass an action parameter in the link and the controller automatically would redirect it to the appropriate class in a file located in the "controllers" folder or subfolder

    Something like http://localhost/modx-2.2.1-pl/manager/index.php?a=79&action=product/create
    It's nice that this action can also define subfolders to help keep things organized.
    In this case it would be redirected to a file named "create.class.php" located in the "controllers/product" subfolder of my namespace core_path containing the MyextraProductCreateManagerController class

    But what if I want to create a direct action menu?

    ModActions also accept path to the action but the path root is the namespace core.
    So..if I want a menu to the product/create action I would have to create a "product" folder in the namespace core path, outside the "controllers" folder.

    Other option is to name the action product_update and have a product_update.class.php in the core_path and redirect to the correct class MyextraProductCreateManagerController.

    None of this options seem elegant to me.
    What is the correct way to create more action menus for my extra?

    Can someone help?
    Thanks
      • 33968
      • 863 Posts
      If I understood you correctly, there's no need to create another action. Simply create a new topmenu item (System > Actions), select your 'MyExtra' action (79), and in the parameters field place:
      &action=product/create
      


      Clear your cache and refresh the manager; the new action will show up in the top menu and will link directly to a=79&action=product/create page
        • 39742
        • 29 Posts
        Yes..I realized that but was wondering the possibility to add sub-menus under the main action menu.
        It's seams possible and is how most core CMP's do it.
        For instance the is a "security/user" action with id 56 and a "security/user/create" with id 33 and a "security/user/update" id 34 although only the first appears in a menu.
        I guess the simplest way is to have the main extra CMP provide access to all other areas.
        Nevertheless would be nice to add submenu action in a straight forward manner.
          • 33968
          • 863 Posts
          Sorry but I'm a bit confused about what you are trying to do... you want a separate sub-menu (not the top menu) inside your CMP which will let you navigate to different pages within that CMP?
            • 39742
            • 29 Posts
            Exactly.

            Instead of having one menu action under the modx "Components" (Components->MyExtra)
            Currently I'm using a main CMP with tabs. The product tab for instance shows a list of products and was a button to create a new product (like users in modx)

            I would like this MyExtra menu with "no action" and have actions as MyExtra subitems.
            Like Components->MyExtra->Create Product, Components->MyExtra->Create Category, Components->MyExtra->Manage Something, etc, etc
              • 18373 ☆ A M B ☆
              • 3,141 Posts
              Easiest way is to just use javascript to link to the current page url with &action=product/create appended. This will route it to your controllers/product/create controller.

              In Revo 2.3 there will no longer be actions (it'll just be there for some backwards compatibility iirc), but you will be expected to use a specific URL syntax (I think it's &a=product/create&namespace=myextra, but don't hold me to that). This will basically take away one step in the development process and slim down the core a tiny bit.
                Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

                Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.
                • 33968
                • 863 Posts
                Ah - there's not really a way to create sub-menu items in the top menu. But what you could do (and I've done many times before), is create a new top level menu item with no action assigned.

                So instead of appearing as a menu item under Components, 'MyExtra' would appear next to it in the top menu and your pages would be available at MyExtra->Create Product, MyExtra->Create Category, etc.

                Does that sound sensible?

                I have also previously used a context menu where you normally see the resource save and cancel buttons to provide an easy way to switch between related CMP actions, although I think the solution above should be sufficient.
                  • 39742
                  • 29 Posts
                  Hi
                  Has Lucas said I want to "...create a new top level menu item with no action assigned.
                  So instead of appearing as a menu item under Components, 'MyExtra' would appear next to it in the top menu and your pages would be available at MyExtra->Create Product, MyExtra->Create Category, etc."

                  I understand routing when using &action=product/create but I can't define that in a action assigned to a menu in the manager...or can I?
                  The only problem is that if I define an action named create/product to assign to a menu in the manager it will search for the file "core_path/product/create.class.php" and not "core_path/controllers/product/create.class.php"
                  Is there a way to change the root for searching controllers for "actions defined in the manager" to "core_path/controllers"

                    • 33968
                    • 863 Posts
                    Quote from: iursetrof at Jun 03, 2012, 11:50 AM
                    Hi
                    I understand routing when using &action=product/create but I can't define that in a action assigned to a menu in the manager...or can I?
                    I mentioned this in an earlier post but perhaps you misunderstood... when you create an action you can add &action=product/create to the 'parameters' field and it will be appended to the action url. So it will go to your product/create page instead of the action root page.
                      • 39742
                      • 29 Posts
                      ahhh....sorry..my bad.

                      I'm using modx 2.2. It doesn't allow parameters.

                      Is modx 2.3 stable? I read somewhere about 2.3 and I got the feeling that development has stopped and was redirected to modx cloud or something.

                      I'm just starting learning modx...should I start with 2.3?