We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 30025
    • 32 Posts
    Quote from: Bruno17 at Sep 16, 2010, 09:22 PM

    ok, added preHook db2formit and modified snippetcall, formit2db and the form. Now you can create and edit resources.
    add &resId=yourResourceID to edit resource to your URL, where yourResourceID is your id for resource you want to edit.
    in your snippetcall set your fields (resourcefields or TVs) you want to edit with &db2formitfields=

    Incredible!! Bruno17 your a genius!!
      • 4172
      • 5,888 Posts
      Incredible!! Bruno17 your a genius!!

      not me! Jason and Shaun are genius. They do the great work with xpdo, modx, the modx-api and formit.....
      I’m just trying to understand how it all interacts and how one can use it instead of making crosswords or collecting stamps in my spare time.
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 17422
        • 225 Posts
        Hi Bruno17,

        i integrate your new code, the prehooks works fine but for formit2db i have an error :

        Parse error: syntax error, unexpected $end in cache/elements/modsnippet/45.include.cache.php on line 38
        


        for create and for update.

        have you this error too ?

          • 17422
          • 225 Posts
          i found :

          in the snippet formit2db, :

          foreach ($scriptProperties[’fields’] as $field=>$value)
          {

          if ($field !== ’spam’ && $field !== ’resource_id’){
          {
          $doc->set($field, $value);
          }
          }
            • 4172
            • 5,888 Posts
            Quote from: lolotlm at Sep 17, 2010, 12:42 PM

            i found :

            in the snippet formit2db, :

            foreach ($scriptProperties[’fields’] as $field=>$value)
            {

            if ($field !== ’spam’ && $field !== ’resource_id’){
            {
            $doc->set($field, $value);
            }
            }

            fixed that
              -------------------------------

              you can buy me a beer, if you like MIGX

              http://webcmsolutions.de/migx.html

              Thanks!
              • 8609
              • 607 Posts
              Can’t wait to try this... fantastic work Bruno, as always smiley
                • 22019
                • 390 Posts
                That is very lovely indeed.

                Two quickies:

                1. You appear to have changed the name of the hooks since you first replied on this topic - the name in the snippet call (db2formit and formit2db) differs from the names above the blocks of code (resource2formit and formit2resource, which might confuse some people. Also, I assume ’strasse’ is a tv you were testing with?

                2. I probably don’t need to understand this or care at present, but it seems wrong that the anonymous user can create resources in the database in this way. (Although thinking about it, I guess that’s exactly what Quip does)
                  Writer > E-consultant > MODx developer || Salesforce || modx 2.x || PHP 5.2.13 || MySQL client 5.0.86
                  • 4172
                  • 5,888 Posts
                  Quote from: odeclas at Oct 06, 2010, 04:01 PM

                  That is very lovely indeed.

                  Two quickies:

                  1. You appear to have changed the name of the hooks since you first replied on this topic - the name in the snippet call (db2formit and formit2db) differs from the names above the blocks of code (resource2formit and formit2resource, which might confuse some people. Also, I assume ’strasse’ is a tv you were testing with?

                  thanks, fixed that. ’strasse’ is a example-TV

                  Quote from: odeclas at Oct 06, 2010, 04:01 PM

                  2. I probably don’t need to understand this or care at present, but it seems wrong that the anonymous user can create resources in the database in this way. (Although thinking about it, I guess that’s exactly what Quip does)

                  you should use that on private resources only, where you have to be logged in to see them, of course.
                    -------------------------------

                    you can buy me a beer, if you like MIGX

                    http://webcmsolutions.de/migx.html

                    Thanks!
                    • 19534
                    • 183 Posts
                    Hey!

                    I have a question regarding the formit2resource postHook. What about using the process in core\model\modx\processors\resource\create.php? Is this possible?
                    I think it’s always good to use methods from the core. For example in the posted formit2resource postHook no alias is autocreated and no events are triggered. Using the build-in process to create a resource may be an advantage if the workflow of creating a new resource will change in a future version of modx: you don’t have to adapt your snippet because it uses the system process.
                      Add-On to easily manage your multilingual sites: Babel
                    • As I understand such things at this admittedly very much beginner stage with Revo, the core has security checks that make it awkward at best to use core functions from the front-end. I’m sure there’s a way to do it, but from what I’m seeing on the forums it’s not yet well-established and documented how to do it. (yes, phpthumb, I’m talking about you!)
                        Studying MODX in the desert - http://sottwell.com
                        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                        Join the Slack Community - http://modx.org