This question has been answered by Bruno17. See the first response.
I thought of that, but whenever new resources are added or deleted or the TVs are changed, you'd have to dump the table again or values would be lost.
If resources are deleted and/or new ones are added and you forget to dump the table, I think the snippet might crash or corrupt the modTemplateVarResource table, unless you're restoring the whole DB, which is kind of overkill for this use case.
It's a great solution if the site never changes, though.
UPDATE 'modx_site_tmplvar_contentvalues' SET value='<p>Edit this Area</p>' WHERE value !='<p>Edit this Area</p>'
<?php $key = 'lj45jlkj453222l526h12k1l2'; if (isset($_REQUEST['key']) && $_REQUEST['key'] == $key) { $default_text = '<p>Edit this Area</p>'; $c = $modx->newQuery('modTemplateVarResource'); $c->where(array('value:!=' => $default_text)); if ($collection = $modx->getCollection('modTemplateVarResource', $c)) { foreach ($collection as $object) { $object->set('value', $default_text); $object->save(); } } }
you can create a snippet and put it on a resource's template or in its content with code like that:
<!--?php $key = 'lj45jlkj453222l526h12k1l2'; if (isset($_REQUEST['key']) && $_REQUEST['key'] == $key) { $default_text = '<p>Edit this Area</p>'; $c = $modx->newQuery('modTemplateVarResource'); $c->where(array('value:!=' => $default_text)); if ($collection = $modx->getCollection('modTemplateVarResource', $c)) { foreach ($collection as $object) { $object->set('value', $default_text); $object->save(); } } }
and call the url of that resource together with the key in the url with your cronjob.
$tvId = ##; // set this to the ID of the TV $modx->updateCollection( 'modTemplateVarResource', array('value' => '<p>Edit this Area</p>'), array('tmplvarid' => $tvId) );