We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 27147
    • 53 Posts
    If you’re offering, I for one think it’s a great idea for a tutorial.

    Any expansion of the docs to help those of us wanting to get our feet wet with the ’framework’ aspect of MODx is welcome IMO.
      • 9549
      • 93 Posts
      Any news here? Some of you have probaly discovered a way for this, like jlivingston! Anyone willing to share?
        • 7231
        • 4,205 Posts
        With some php/mysql knowledge you could do this with eForm2db, after all it is only a database query. The advantage here is that you get to take advantage of the validation available in eForm. I have not tried this but in theory it should work.

        http://modxcms.com/forums/index.php/topic,8111.0.html
          [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

          Something is happening here, but you don't know what it is.
          Do you, Mr. Jones? - [bob dylan]
          • 21257 MODX Staff
          • 730 Posts
          I just posted something on this in another thread. Paraphrased:

          I hacked around quite a few months back in order to create a "document editor" where you could edit a document’s template variables in the front end.
          It was basically a reworking of the NewsEditor snippet, plus I nicked a bunch of code from the manager side to get the tv field rendering to come out properly.

          Quote from: jlivingston at May 28, 2007, 09:15 AM

          ... though I can see that development of a general-use snippet for this purpose could get quite hairy.
          ... Perhaps just as helpful, or even more helpful, than writing a general purpose snippet, would be to write a tutorial on how to do this?

          I concur. Initially I set about designing my DocumentEditor in a generalized way, so that I might contribute it to the community. But it ended up being too much of an undertaking considering that I was probably billing about $5.00 for the work. There’s more to it than one snippet - and the solution is still a bit specific to my particular implementation.

          With 0.9.7 on the horizon, would a tutorial on how to do this still be valuable?
            Mike Schell
            Lead Developer, MODX Cloud
            Email: [email protected]
            GitHub: https://github.com/netProphET/
            Twitter: @mkschell
            • 36592
            • 970 Posts
            This hack may work for PHP specialist...

            http://modxcms.com/bugs/task/129
              • 10449
              • 956 Posts
              I think using the DocManager class could come in handy: http://www.modxcms.com/Docmanager-881.html / http://modxcms.com/forums/index.php/topic,5983.0.html

              Can’t beat it for brevity:

              require_once(’assets/libs/docmanager/document.class.inc.php’);
              $doc = new Document($id,’content’);
              $content=$doc->Get(’content’);
              $doc->Set(’tvName’,’some updated stuff’);
              $doc->Save();
                • 22303 MODX Staff
                • 10,725 Posts
                Good call ganeshXL. This approach is also quite similar to the new 0.9.7 API’s for doing the same, so if you can encapsulate any complex usage of DocManager class, you should be able to easily migrate the code to the 0.9.7 native API, e.g.
                <?php
                $tv = $modx->getObject('modTemplateVar', array('name' => 'tvName'));
                if ($tv) {
                    $tv->setValue($documentId, 'some updated stuff');
                }
                ?>