Hi All,
I'm new to Modx and would like to understand how we can write to a flat file which is stored on the server. I tried basic fopen command which doesn't even allow the snippet to be saved. The file_put_contents also doesn't seem to work.
Appreciate any help.
Thanks,
Sikki
If a snippet with that code won't save, the problem is almost certainly a modx_security setting the hosting service has created.
http://wiki.modxcms.com/index.php/What_is_mod_security_and_how_does_it_affect_me
Thanks Bob. Yes, the server was blocking any form of file write.
Also, the information you posted regarding DB update was very helpful and I was able to create custom table and update records.
Could you please help me understand how we can retrieve data from DB and populate FormIT forms.
Appreciate any help you can provide in this regard.
That's generally done with placeholder tags in the forms.
In a snippet near the top of the page (or in the template), you set all the placeholders with something like this (untested, off the top of my head):
$object = $modx->getObject('someClassNameHere', $criteria);
if ($object) {
$fields = $object->toArray();
$modx->setPlaceholders($fields);
}
return "";