We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 27226
    • 186 Posts
    huh What’s the trick with the parent here?
    Sorry, I don’t get your intention! Is it important for a (new) doc to have a parent?
    And how should I set a parent, when I can not even create a "child"?
    Could you please explain that in more detail?

      • 13003
      • 18 Posts
      Quote from: silent at Aug 14, 2006, 06:29 PM

      huh What’s the trick with the parent here?
      Sorry, I don’t get your intention! Is it important for a (new) doc to have a parent?
      And how should I set a parent, when I can not even create a "child"?
      Could you please explain that in more detail?



      I too, would be interested in a response to this question
        • 7923
        • 4,213 Posts
        Document must have parent attribute set ofcourse.. where would the new document appear in site tree if there weren’t any parent id given to it? If document should be created to site root, the parent id should be 0.

        When looking at the source of this class, it seems to give the document parent id 0 by default allways when creating new document, so not sure if that’s the problem, but here’s how you can set it:

        $doc = new Document();
        $doc->Set(’parent’,69);
        ...
        $doc->Save();


          "He can have a lollipop any time he wants to. That's what it means to be a programmer."
          • 16556
          • 27 Posts
          Hello, I am trying to use this docapi to create a document and set a TV.. I am not sure if i am missing something very basic?

          I created a snippet "AddBlog" with the following code:

          require_once(’../new/assets/libs/docapi/docmanager.class.inc.php’);

          $submited=isset($_POST[’submit’]);

          if(!$submited) {
          return $modx->getChunk(’AddBlogEntryForm’);
          }
          else{
          $doc = new Document();
          $doc->Set(’parent’,2);
          $doc->Set(’content’,$_POST[’content’]);
          $doc->Set(’tvcategoryOptions’,$_POST[’tvcategoryOptions’]);
          $doc->Save();
          }

          but i get the following error when i load the page with the call [!AddBlog?!]

          « MODx Parse Error »
          MODx encountered the following error while attempting to parse the requested resource:
          « PHP Parse Error »

          PHP error debug
          Error: Unknown(../new/assets/libs/docapi/docmanager.class.inc.php): failed to open stream: Permission denied
          Error type/ Nr.: Warning - 2
          File: /data03/virt11978/domeenid/www.domain.com/htdocs/new/manager/includes/document.parser.class.inc.php(705) : eval()’d code
          Line: 1

          Parser timing
          MySQL: 0.0011 s s (0 Requests)
          PHP: 0.0382 s s
          Total: 0.0394 s s

          The error says permission denied, so i have tried changing permissions to 777, but i doesn’t change anything.. (Sorry my PHP knowledge is very limited but trying to learn slowly.) If anyone has ever had a silimar error and could help would be greatly aprhesiated. thanks lach.
            • 22303 MODX Staff
            • 10,725 Posts
            Your path to the docmanager class is wrong. The path in a snippet is always from the root of the site, and if you have base_dir restrictions in effect, you have to include the full path on the server, so you can do...
            include_once($modx->config['base_path'] . 'assets/libs/docapi/docmanager.class.inc.php');

            ...to make your code work in any environment.
              • 16556
              • 27 Posts
              thanks opengeek for replying so fast.. i just tried what you suggested but i don’t think the path was the problem? as i still get the same error??? :

              PHP error debug
              Error: Unknown(/data03/virt11978/domeenid/www.domain.com/htdocs/new/assets/libs/docapi/docmanager.class.inc.php): failed to open stream: Permission denied
              Error type/ Nr.: Warning - 2
              File: /data03/virt11978/domeenid/www.domain.com/htdocs/new/manager/includes/document.parser.class.inc.php(705) : eval()’d code
              Line: 1

              Is there anything else that i am doing wrong that might be causing the permission denied error? thank you very much for helping me. thanks lach.
                • 22303 MODX Staff
                • 10,725 Posts
                Quote from: lach at Oct 27, 2006, 08:18 PM

                thanks opengeek for replying so fast.. i just tried what you suggested but i don’t think the path was the problem? as i still get the same error??? :

                PHP error debug
                Error: Unknown(/data03/virt11978/domeenid/www.domain.com/htdocs/new/assets/libs/docapi/docmanager.class.inc.php): failed to open stream: Permission denied
                Error type/ Nr.: Warning - 2
                File: /data03/virt11978/domeenid/www.domain.com/htdocs/new/manager/includes/document.parser.class.inc.php(705) : eval()’d code
                Line: 1

                Is there anything else that i am doing wrong that might be causing the permission denied error? thank you very much for helping me. thanks lach.
                What is the actual full path to that file on your server? Check where this file that is reported as Unknown actually exists and compare it to that path in which it is looking for it...
                  • 16556
                  • 27 Posts
                  thanks again for helping opengeek, i have just been trying it again and the page now seems loads with no errors.. but when i submit the form no doc gets created?

                  Is there anyway if i can see if the doc m api is executing properly, or is there somethign i need to add somewhere else to the snippet code:

                  include_once($modx->config[’base_path’] . ’assets/libs/docapi/docmanager.class.inc.php’);

                  $submited=isset($_POST[’submit’]);

                  if(!$submited) {
                  return $modx->getChunk(’AddBlogEntryForm’);
                  }
                  else{
                  $doc = new Document();
                  $doc->Set(’parent’,2);
                  $doc->Set(’content’,$_POST[’content’]);
                  $doc->Set(’tvcategoryOptions’,$_POST[’tvcategoryOptions’]);
                  $doc->Save();
                  }


                  thanks for any help. thanks lach.
                    • 9549
                    • 93 Posts
                    got the same problem.

                    my code looks like this:

                    <?php
                    require_once($modx->config[’base_path’] . ’assets/libs/docmanager/document.class.inc.php’);
                    $submited=isset($_POST[’submit’]);

                    if(!$submited) {
                    return $modx->getChunk(’LaggTill’);
                    }
                    else{
                    $doc = new Document();
                    $doc->Set(’parent’,$folder);
                    $doc->Set(’alias’,’post’.time());
                    $doc->Set(’content’,’content’);
                    $doc->Set(’template’,’VMD’);
                    $doc->Set(’tvyrsModel’,’tvyrsModel’);
                    $doc->Save();
                    }
                    ?>
                      • 3232
                      • 380 Posts
                      anyone able to figure out the problem on the last post?