On March 26, 2019 we launched new MODX Forums. Please join us at the new MODX Community Forums.
Subscribe: RSS
  • 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!!
    • 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!
      • 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 ?

        • i found :

          in the snippet formit2db, :

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

          if ($field !== ’spam’ && $field !== ’resource_id’){
          {
          $doc->set($field, $value);
          }
          }
          • 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!
            • Can’t wait to try this... fantastic work Bruno, as always smiley
              • 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
                • 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!
                  • 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