Here is what I am trying to do.
If there is an empty image field on a node I want it replaced based on what taxonomy terms are on the page, but the key is I want to apply it site wide so it will affect not only the tpl files but Views as well. I'm guessing this needs to be done via mytheme_preprocess_field in template.php but I'm not quite sure how to do it.
I can easily do this in node.tpl.php but I need it done site wide, not just in the node-type template.
- VID 1
- TID 1
- TID 2
- TID 3
- TID 4
- VID 2
- TID 5
- TID 6
- TID 7
- VID 3
- TID 8
- TID 9
- TID 10
Here is what I am trying to do.
// Set Variables
$term1 = $content['field_term1'][0]['#markup'];
// Must use if statement or else there will be an error
if ( isset( $content['field_term2'][0]['#markup'] ) ) {
$term2 = $content['field_term2'][0]['#markup'];
}
// Must use if statement or else there will be an error
if ( isset( $content['field_term3'][0]['#markup'] ) ) {
$travel_type = $content['field_term3'][0]['#markup'];
}
if (isset($content['field_node_image'][0]['#item']['uri'])) {
$image_path = file_create_url($content['field_node_image'][0]['#item']['uri']);
} else {
switch ($term1) {
case 'TID 1':
switch ($term2) {
case 'TID 5':
$term_type = '5';
break;
case 'TID 6':
$term_type = '6';
break;
case 'TID 7':
$term_type = '7';
break;
}
break;
case 'TID 2':
$term_type = '2';
break;
case 'TID 3':
switch ($term3) {
case 'TID 8':
$term_type = '8';
break;
case 'TID 9':
$term_type = '9';
break;
case 'TID 10':
$term_type = '10';
break;
}
break;
case 'TID 4':
$term_type = '4';
break;
}
$image_path = '/sites/all/themes/themename/term-images/' . $term_type . '.jpg';
}