Have it do its thing only if the document does not already have a given title. If the document’s title is $_lang[’untitled_document’] (or $_lang[’untitled_weblink’]), that will trigger the replacement function.
Looking at the save_content.processor.php file, I believe you could use the onBeforeDocSave event and check the value of $pagetitle and replace it if necessary in the plugin. No database action needed.
Something like
if($pagetitle == $_lang['untitled_document'] || $pagetitle == $_lang['untitled_weblink']) {
$pagetitle = ??; // maybe $tmplvars['tvname'][1]
}
I’m still puzzlling over the save code for TVs to try to figure out how the TV data is passes in the POST. It looks like maybe &_POST[’tv’][’tvname’], but that can also be an array (in the case of select and check boxes), so it gets a bit tricky. I think it would be $tmplvars[’tvname’][1]...
If you have a default, then all that goes out the window!