Hi,
I’m packaging a few templates for revolution, so far so good with simple ones but to save much code searching .... I’m packaging a template with some chunks and two TV’s, I want to relate the TV’s to the template in the transport package, so I’ve created the rest of package OK, and I’ve created an XPDO object modTemplateVarTemplate to hold the mapping from templateid to tmplvarid for the template to the template variables. I used addOne to do this on the modTemplateVarTemplate object and packed it into the package thus :-
$c = $modx->newObject('modTemplateVarTemplate');
$c->addOne($template);
$c->addOne($tvs[0]);
$c->addOne($tvs[1]);
$mapping = $c;
.
.
.
$mapvehicle = $builder->createVehicle($mapping, array (
XPDO_TRANSPORT_PRESERVE_KEYS => false,
XPDO_TRANSPORT_UPDATE_OBJECT => true,
XPDO_TRANSPORT_UNIQUE_KEY => 'tmplvarid'));
$builder->putVehicle($mapvehicle);
I get no errors on packaging, nor on install, the package is installed OK without the template/template variable mapping, a single row is inserted into this table with values of ’0’.
Ok, what attributes do I need to set here, obviously at packaging time no indexes are known, so I’m using my own(1,2,3 etc) and setting the XPDO_TRANSPORT_PRESERVE_KEYS => false attribute. if I don’t do this the addOne fails with a ’NULL field error’.
Is my thinking correct here or is there an easier way to do this?