We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 24374
    • 322 Posts
    I've got this code in a script:

    $tvfilt = '';
    if(!empty($category)) {
    	$tvfilt = 'pubcategory==%' . trim($category) . '%' ;
    }
    
    $pdo = $modx->getService('pdoFetch');
    $resources = $pdo->getCollection('modResource', array(
    	'published' => 1,
    	'deleted' => 0,
    	'parent' => 180
    ), array(
    	'includeTVs' => 'pubauthors,publink,pubpublication,pubyear,pubcategory',
    	'sortby' => 'publishedon',
        'sortdir' => 'desc',
    	'tvFilters' => $tvfilt
    ));

    It works fine if no TV filter is entered. If there IS a filter ("category" add to the script call), though, although it is finding resources with parent ID 180, it is also including unpublished and deleted resources! Why does including a tvFilter make pdoFetch ignore published and deleted parameters?