We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 17016
    • 138 Posts
    Is there any way to submit variables to the controller file regarding Custom Manager Pages?

    Our goal is to read in the controller file a certain TV out of a certain resource. The ID of the resource should be submitted to the controller file by clicking on the created menu object.

    Does anybody know how this works?

    Thanks for any hint what we have to do for this.

    Letti
      • 23571
      • 223 Posts
      I know that this doesn’t directly answer you question, but I use a document to create a config page (with a unique template and TVs) and have been using a plugin to then redirect the user to that document on login. http://www.gregorysmart.com/2011/07/18/revo-config-page-tips/
        • 17016
        • 138 Posts
        You are right. I am not looking for a config page, but for a possibility to transfer data from modx to new controller files and reverse.

        Does anybody know how to realize this?

        Letti
          • 17016
          • 138 Posts
          I created a resource named core/components/controllertest/index.php containing a snippet in which the content is <?php return "yes";

          When calling this file directly by typing in http://www.domain.com/core/components/controllertest/index.php the output is correctly "yes", but when calling this file by an action which is linked in the revolution´s Top Menu we get the error: Could not find action file at: /root/as120412/core/components/controllertest/index.php

          Does anybody understand why this doesn´t work? If it is possible to make this technique work we could transfer data from the controller-files to modx and reverse or use chunks in the controller-files.

          Hope anybody knows what we did wrong and how we can make it better...

          Letti

            • 3749
            • 24,544 Posts
            See if this helps:

            Here is a description of the fields in the Update Action dialog:

            Controller — The name of the file that will be executed (.php is appended to it).

            Namespace — The namespace of the action (determines the path to the file and any lexicon topic files).

            Load Headers — If checked, the file’s output will be displayed surrounded by the Manager UI.

            Language Topics — Lexicon topics to load for the action.

            Assets — Currently not used by MODX.
              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
              • 17016
              • 138 Posts
              Hi Bob,
              Quote from: BobRay at Aug 04, 2011, 12:52 AM

              See if this helps:
              Controller — The name of the file that will be executed (.php is appended to it).
              We followed exactly this manual and created a controller-file, but we created it by modx as a resource (not by an external editor) to be able to transfer data from other modx-resources to the controller-file by using chunks, tvs and so on. But this approach failed like written in my last post.

              Therefore we are looking for another solution to transfer data dynamically into the controller-file.

              Can you give us any idea how we could reach this?

              Thanks a lot
              Letti
                • 4172
                • 5,888 Posts
                if you want to create CMPs in a very simple way (just by creating snippets) you can try this method:
                http://modxcms.com/forums/index.php/topic,54729.msg315441.html#msg315441
                  -------------------------------

                  you can buy me a beer, if you like MIGX

                  http://webcmsolutions.de/migx.html

                  Thanks!
                  • 3749
                  • 24,544 Posts
                  MODX will automatically look for a disk file when a controller is called. I doubt if it can be changed to use a resource.

                  The index.php controller file can use xPDO to access any MODX object in the DB, so it can access TVs, chunks, resources, resource fields, etc. quite easily.
                    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
                    • 17016
                    • 138 Posts
                    Hi Bob,

                    thanks for this hint. I just tried it but it seems like I did anything wrong when trying to get the ID of a child of the resource 1158 (only for test-reasons I added the foreach and echo-tags):

                    $resource = $modx->getObject('modResource', 1158);
                    $children = $modx->resource->getMany('Children');
                    
                    foreach($children as $child) echo $child;
                    return;


                    For the second line I got this error:
                    Fatal error: Call to a member function getMany() on a non-object
                      • 3749
                      • 24,544 Posts
                      That’s because the current resource has no children.

                      Take out $modx-> in the second line. You want the resource you retrieved, not the current resource.

                      Also, you can’t echo the resource because it’s an object, not a string. You want

                      echo $modx->resource->get(’pagetitle’);

                      And, you should always test to make sure you have an object before calling one of its methods:

                      if($resource)

                      if (! empty($children))



                        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