$dateFormat = $modx->getOption('dateFormat', $scriptProperties, 'Y-m-d H:i:s');
$checkTime = $modx->getOption('checkTime', $scriptProperties, date($dateFormat, time()) );
$migxResourceId = $modx->getOption('migxResourceId', $scriptProperties, false );
$migxTVName = $modx->getOption('migxTVName', $scriptProperties, false );
$migxCheckField = $modx->getOption('migxCheckField', $scriptProperties, false );
$resourceCheckTV = $modx->getOption('resourceCheckTV', $scriptProperties, false );
if( !$migxResourceId || !$migxTVName || !$migxCheckField ||!$resourceCheckTV ) return '';
if( !$migxResource = $modx->getObject('modResource', $migxResourceId) ) return '';
// get MIGX data as array
$migxEntries = $migxResource->getTVValue($migxTVName);
if( $migxEntries == '' ) return '';
$migxEntries = json_decode($migxEntries);
// get array with resource ids
$resource_ids = array();
foreach( $migxEntries as $entry ) {
$resource_ids[] = $entry->$migxCheckField;
}
// get all resources with these ids
$q = $modx->newQuery('modResource');
$q->where( array(
'id:IN' => $resource_ids
));
$resources = $modx->getCollection('modResource',$q);
// delete old migxEntries
foreach( $resources as $resource ) {
$resourceDate = $resource->getTVValue($resourceCheckTV);
if( $resourceDate != '' && $resourceDate < $checkTime ) {
// delete entry with resource's id
foreach( $migxEntries as $key => $entry ) {
if( $entry->$migxCheckField == $resource->id ) {
array_splice($migxEntries, $key, 1);
break;
}
}
}
}
// store new values in MIGX TV
$tv = $modx->getObject('modTemplateVar',array('name' => $migxTVName));
$tv->setValue($migxResourceId, json_encode($migxEntries));
$tv->save();
return '';[[ !MIGX_removeOldEntries? &dateFormat = `Y-m-d H:i:s` &checkTime = `2011-03-12 00:00:00` &migxResourceId = `24` &migxTVName = `myMIGXTV` &migxCheckField = `resourceid` &resourceCheckTV = `eventDate` ]]
I am new to migx (and generally to modx) and whatever I do to install it, I can not see migx as input type when I try to create new tv, just regular ones (text, image, etc).
Sorry if this's been asked before. Using modx 2.1.3 and latest migx.
Quote from: encho at Oct 12, 2011, 11:41 AMI am new to migx (and generally to modx) and whatever I do to install it, I can not see migx as input type when I try to create new tv, just regular ones (text, image, etc).
Sorry if this's been asked before. Using modx 2.1.3 and latest migx.
After installation per package-manager there should be a plugin for migx.
Is it?
[[getImageList?
&tvname=`migxProducts`
&where=`{"productGroupName:=":"[[+productGroupName]]","productItemType:=":"product"}`
&tpl=`migxProductsListRowTpl`]]
After installation per package-manager there should be a plugin for migx.
Also, for MIGX + Revo 2.2 compatibility this patch came in handy: https://gist.github.com/1266540added this patch with the last github-commit, but didn't test it myself.
This discussion is closed to further replies. Keep calm and carry on.