The ManagerManager rule would always synch, not just when the destination field is empty.
Okay, so that has reminded me that when a default value is set for the template variable as you have been doing this only has effect until the field is modified. In that way by default all languages show the default language (English in your case), until you add a translation. It’s such a shame that this approach doesn’t work well with Ditto.
In that case the only solution I can think of is a custom plugin that works on the OnBeforeDocFormSave event. The following is completely untested, but it might just work... Use at your own risk! You’ll have to create a new plugin called YAMSUseDefaultLanguageWhenEmpty or perhaps something more elegant, set it to be active on the OnBeforeDocFormSave event and use the following code:
// Get the current document id
$evt = &$modx->Event;
switch ( $evt->name )
{
case 'OnBeforeDocFormSave':
// We'll need to access the MODx template variables array...
global $tmplvars;
// Loop over all the fields that should be synchronised
$fieldsToSynchronise = array(
'pagetitle'
, 'longtitle'
, 'description'
, 'introtext'
, 'content'
, 'menutitle'
);
// Get the current document id
$docId = $evt->params['id'];
// Instantiate YAMS
require_once( dirname( __FILE__ ) . '/class/yams.class.inc.php' );
require_once( dirname( __FILE__ ) . '/yams.module.funcs.inc.php' );
$yams = YAMS::GetInstance();
// Get the default language id
$defaultLangId = $yams->GetDefaultLangId();
// Check if the current document is multilingual
$isMultilingualDocument =
$yams->IsMultilingualDocument( $docId )
|| $yams->IsMultilingualTemplate( $template );
while ( $isMultilingualDocument )
{
// Loop over all language ids except the default one...
foreach ( $yams->GetActiveLangIds() as $langId )
{
if ( $langId == $defaultLangId )
{
continue;
}
foreach( $fieldsToSynchronise as $field )
{
// Calculate the tv name
$tvName = $field . '_' . $langId;
// Get its id...
$tvId = YAMSGetTempVarId( $tvName );
if ( $tvId === FALSE )
{
continue;
}
// Get its identifier...
$tvIdentifier =
YAMSTVDataToMMName( $tvName, $tvId, '' );
if ( ! array_key_exists( $tvIdentifier, $tmplvars ) )
{
if ( ! array_key_exists( $tvName, $tmplvars ) )
{
continue;
}
else
{
// The tv has been marked for deletion
// because it is empty.
// Undo that...
unset( $tmplvars[ $tvName ] );
// Set it's value to an empty string for the moment...
$tmplvars[ $tvIdentifier ] = array(
$tvIdentifier
, ''
);
}
}
// If the tv is empty...
if ( $tmplvars[ $tvIdentifier ][1] == '' )
{
// Use the default language placeholder...
$tmplvars[ $tvIdentifier ][1]
= '((yams_data:' . $docId. ':' . $field . '_' . $defaultLangId . '))';
}
}
}
break;
}
break;
}
This should, I think, set the value of an empty non-default language field to [tt]((yams_data:
docId:
field_
defaultLangId))[/tt].
For this to work you’ll need to reset the default value of your tvs to blank. You may need to delete existing tv values and resave the document for the plugin to work.
EDIT: Please let me know if this works. If so, then I think that there are quite a few other people who might be interested in this plugin or variants of it.