Sorry.... but i’m new on the revolution modx..
I have the last problem solved, but now I don’t know how add value to the Tv’s
I create the template and the tv’s on the modx and now I want create automaticaly the document with the values of the tv’s
On the last version of the modx I used the function
$modx->SetTV(’title’,$_POST[’title’]);
And now how I do?
Hi again
Reading you code I understand you have a TV named ’title’ and another one named ’data’ is this right ?
If yes, it is possible that using "title" as name for a TV was not a good idea... I’m not really sure of that but I remember I encountered some issues due to bad choice in naming elements. To prevent that I avoid all names that can be confused with "reserved" ones... (like "title") or I prefix them with something of my own like ’myTitle’ something I’m pretty sure is not used by the system...
Hope this helps
Cheers
Thanks I didn’t know that
But apart of that the code it’s correct?
I ask you because I don’t get the value on the tv’s
yep it seems to be correct ... But I’m not a guru ... Maybe there is something wrong that I don’t see
Cheers
see my example I linked above. There it is done like that:
<?php
$doc = $modx->newObject('modDocument');
$doc->set('parent',2);
$doc->set('alias',$_POST['title']);
$doc->set('pagetitle',$_POST['title']);
$doc->set('template',2); // Id of the template
$doc->set('published',1);
$doc->set('cacheable',0);
$doc->set('hidemenu',1);
$doc->save();
$fields['title']=$_POST['title'];
$fields['data']=$_POST['date'];
foreach ($fields as $field=>$value)
{
if ($tv = $modx->getObject('modTemplateVar', array ('name'=>$field)))
{
$tv->setValue($doc->get('id'), $value);
$tv->save();
}
}
return true;
you forgot:
for each TV
Quote from: sjscosta at Oct 08, 2010, 03:46 AM
Thanks a lot 
Finally it’s working
Sorry -- my fault for leaving $tv->save() out of my example.
Glad you got it working.