solved!
i have some mess in DB and have some TV values with contentid's of non existing pages? is there any easy and safe way to clean it?
Any idea how that happened?
I think this would clean them up (Back up the DB first! and clear the site cache before running this) -- this is off the top of my head and untested:
<?php
$tvResources = $modx->getCollection('modTemplateVarResource');
$count = 0;
foreach($tvResources as $tvResource) {
$docId = $tvResource->get('contentid');
$doc = $modx->getObject('modResource', $docId;
if (! $doc) {
$tvResource->remove();
$count++;
}
}
return ('Removed ' . $count . ' TemplateVarResources');