New version 0.5.3b
Added: $doc->Duplicate() function
I’m just going to give a try to your api, is it 0.9.5 compliant ?
I’m interested in the 095 compatibility, too. What’s the answer?
its 095 compliant im using it on 095 myself now...
i would like to know however how i can get the id of the newly created document... i cant see anyway ATM... please get back ASAP...
I just make some test, the api seems to work well on the new version, you must add an escape function in the save() one, because fields aren’t correctly escaped if you have ", ’ ,... in your text fields.
This API rocks !
Very Quick Guide:
Be carrefull : The doc group aren’t managed (for the moment ?).
to create a new document:
[tt]$doc = new Document(); // [/tt]
to get an existing document:
[tt]$doc = new Document($id); // Where $id contain the id of the document you want do get.[/tt]
to get a field from a document:
[tt]$pagetitle=$doc->Get(’pagetitle’);[/tt]
to get a tv value from a document:
[tt]$MyTvValue=$doc->Get(’tvMyTvName’);//add "tv" before the name of your tv.[/tt]
to set a field: (you must call Save() to save the change in the db)
[tt]$doc->Set(’pagetitle’,’My New PageTitle’);[/tt]
to save your modifications in the db:
[tt]$doc->Save();[/tt]
after the save of a new doc you can get the new id created:
[tt]$MyNewId=$doc->fields[’id’];[/tt]
to duplicate a document (document are duplicated with their tv values):
[tt]$doc = new Document($Id_Of_Document_You_Want_Duplicate);
$doc->Duplicate();
$doc->Save();
[/tt]
Hope this help.
Quote from: Aikdo at Dec 30, 2006, 06:39 AM
Quote from: Soda at Dec 30, 2006, 03:33 AM
after the save of a new doc you can get the new id created:
$MyNewId=$doc->fields[’id’];
This is just what i wanted to know thank you... I can finish my application now 
And if you need the id before the document is saved, use $modx->db->getInsertId() (if no-one else can save a document in the mean while)
"He can have a lollipop any time he wants to. That's what it means to be a programmer."
one thing I notice, be carefull, the tvs are filled only if you do a get field on it.
line 126 in the GetTV function the call to getTVValues() , this function doesn’t exist, I replaced it with fillOldTVValues(), don’t know if its right, ur001 can you help me ?