We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 11694
    • 13 Posts
    Hello everybody
    I get a strange error message:
    Warning: Call-time pass-by-reference has been deprecated - argument passed by value; If you would like to pass it by reference, modify the declaration of [runtime function name](). If you would like to enable call-time pass-by-reference, you can set allow_call_time_pass_reference to true in your INI file. However, future versions may not support this any longer. in f:\program files\easyphp1-8\www\modx\modx-0.9.5\assets\libs\docapi\document.class.inc.php on line 78

    i also get this for line 74

    if i delete the reference handler (&) from the 74,78 lines, then everything seems to work fine...or is not?
    should i keep on using it like this or should i go and change the ini?
    anyone? undecided
      • 31113
      • 45 Posts
      Yes, if your PHP<5.0
        • 3743
        • 42 Posts
        doc api does not work with 0.9.6 with TV’s. It can read common page values like pagetitle but now tv’s. can you fix it please?
          • 10449
          • 956 Posts
          I’ve used it with 0.9.5 + 0.9.6 with TVs - works fine here...
            • 10449
            • 956 Posts
            fwiw, here’s a fully functional, basic example (0.9.6. on LAMP setup), running as a standalone PHP script:

            <?php
            
            include_once('../../modxapi.php'); // include the API class
            $modx = new MODxAPI();
            $modx->connect();
            $modx->getSettings();
            
            require_once('../libs/docmanager/document.class.inc.php'); // include the docmanager class (d'oh)
            
            $doc = new Document();
            $doc->Set('pagetitle', "Dinner was delicious!");
            $doc->Set('parent', 56);
            $doc->Set('alias', 'post'.time());
            $doc->Set('content', 'Oh, hello! This is a new post generated via the docManager class.');
            $doc->Set('template', 'basic');
            $doc->Set('cacheable', 0);
            $doc->Set('hidemenu', 0);
            $doc->Set('tvpageKeywords', 'API, MODx, development, tests'); // TV 1 - TV name = pageKeywords
            $doc->Set('tvpageDescription', 'Just a basic test using the (3rd party) docManager class from an external PHP script.'); // TV 2 - TV name = pageDescription
            
            $doc->Save();
            $newID = $doc->fields['id'];
            
            // alternatively, use $modx->makeUrl($newID) if SEO-friendly URLs are activated
            echo "New document was created: <a href='http://www.mysite.com/index.php?id=$newID' target='_blank'>id #$newID</a>";
            
            ?>
            
            



            imo, you really only need to remember to include the modx api class*, and add "tv" prefix.
            So, if your TV is called "keywords", use "tvkeywords" instead. That’s really all there is to it.
            I’ve used this now on at least 3 different sites, from 0.9.5 to 0.9.6.1, WAMP + XAMPP without problems.

            It can really be a great timesaver when you have to copy old content from a DB to a new site with MODx. I’m not saying it’s the only tool around. There’s the CSV importer, FDM, and probably other stuff I’ve missed. But this has been working nicely for me.


            * if it’s running inside a snippet, you don’t need that of course
              • 27330
              • 884 Posts
              Does one suppose to create the snippet and call it right after the NewsPublisher snippet call?
              Do I need to insert all the TV’s I want to set their values with NewsPublisher into the snippet code
              $doc->Set('tvSampleTV','sample tv');
              or any TV will be available?
                • 27330
                • 884 Posts
                anyone mind explaining a n00b how can I insert data to TV’s from frontend?
                I read over and over the posts but can’t figure how to make it work.

                Do I need both this library and the docAPI lib or this is an alternative as the title says?
                is this goes in addition to the NewsPublisher snippet or I need to include the lib with NewsPublisher snippet?
                Seems like many understood how to use it and I want too smiley
                a little confused and would appreciate any help.
                  • 36416
                  • 589 Posts
                  Quote from: sinbad at Feb 03, 2008, 10:48 AM

                  anyone mind explaining a n00b how can I insert data to TV’s from frontend?

                  I suggest entirely different snippet for editing/inserting TVs - FDM:
                  http://modxcms.com/forums/index.php/topic,14977.0.html
                    • 27330
                    • 884 Posts
                    thx for the link mate. just what I needed. now I have a form up and running!
                    thanks!
                      • 11694
                      • 13 Posts
                      Hello guys
                      I encountered a problem with the cache. When i use this snippet to create a new document it will not show up in a list at the frontend (created by ditto) unless I clear the cache of the site at the backend.
                      I’ve already found a work around but could somebody tell me if I’m doing something wrong?
                      If not I can submit my hack
                      Cheers