$def['type'] = $d['fieldtype'];
} elseif (empty($def)) {
    print '<p>' . sprintf(__('Invalid fieldname: %s', CCTM_TXTDOMAIN), '<em>' . htmlspecialchars($fieldname) . '</em>') . '</p>';
    return;
}
// Set up search boundaries (i.e. the parameters used when nothing else is specified).
// Load up the config...
$possible_configs = array();
$possible_configs[] = '/config/post_selector/' . $fieldname . '.php';
// e.g. my_field.php
$possible_configs[] = '/config/post_selector/_' . $def['type'] . '.php';
// e.g. _image.php
$possible_configs[] = '/config/post_selector/_relation.php';
// default
//print '<pre>'.print_r($possible_configs,true).'</pre>'; exit;
CCTM::$post_selector = array();
CCTM::$search_by = true;
// all options available if the tpl passes them
if (!CCTM::load_file($possible_configs)) {
    print '<p>' . __('Post Selector configuration file not found.', CCTM_TXTDOMAIN) . '</p>';
}
// This gets subsequent search data that gets passed when the user refines the search.
$args = array();
// Do not set defaults here! It causes any values set in the config/post_selector/ files
// to be ignored. See https://code.google.com/p/wordpress-custom-content-type-manager/issues/detail?id=537
//$args['orderby'] = 'ID';
//$args['order'] = 'ASC';
if (isset($_POST['search_parameters'])) {
    // e.g. fieldname=movie_clip&fieldtype=media&page_number=0&orderby=ID&order=ASC
    parse_str($_POST['search_parameters'], $args);
    //print '<pre>'.print_r($args,true).'</pre>'; exit;