hello
I wanted to do some modification on document content before saving document. I wrote small plugin and attached it to OnBeforeDocFormSave event.
My qustion is, how to modify content - I tried to modify $_POST[’ta’], but it does not work, tried to modify $modx->documentContent, but it is empty...
Where can I effectively modify content?
$_POST-vars are stored in vars before onBeforeDocFormSave and you cannot modify these vars in these event,
but you can modify the saved content in onDocFormSave for example with
$fields['parent']='15';
$table=$modx->getFullTablename('site_content');
$modx->db->update($fields,$table,'id='.$params['id']);
Interesting!
I’m trying to write a plugin that duplicates the document if parent ID is something.
Can I get the parent value or a tv value?
you can get the parent value or tv values in the $_POST-var
see also here:
http://modxcms.com/forums/index.php?topic=44285.0
but the idea to hack the core is not the best, when you have alternatives
Well, it’s not exactly core hacking. Besides it is quite strange, that there is no access to content via document object, because I would expect in this event possibility to modify document data. Your solution is also interesting, but it needs additional db query...