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."
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.
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.
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.
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();
}
?>
anyone able to figure out the problem on the last post?