I want to hook into a snippet after the user updates a resource. For example, I have a resource with an image TV so the user can select an image to accompany a product description. Once the image is selected and the resource is saved I want to be able to automatically run a snippet on the resource, check if it’s image has changed, and if so take the new image and resize it and perform other functions on it. Is this somehow possible with Evo?
Yes, you want a plugin, rather than a snippet, though. The plugin would be tied to the OnDocFormSave system event and its code would execute whenever a resource is saved.
See:
http://www.sottwell.com/how-plugins-work.html
cool, okay, delving into plugins and finding them pretty cool. Writing the plugin now to resize TV images.
One problem I have come up with is removing spaces from the image filenames of a TV. I can rename the file without the spaces easily enough, thats a no-brainer, but how to update the value of the TV to reflect the new filename - there seems to be no $modx->setTemplateVar function.
okay, got around the lack of $modx->setTemplateVar function by using a $modx->db->update to manually update the template var content values table. But surely there is a better way of achieving this??
There is in MODx Revolution.