I want to customize the output of a field on my site so I made a custom views template. Here's the code:
<?php foreach ($row->field_field_location_taxonomize_terms as $data): ?>
<?php if ($data['rendered']['#markup'] == 'Unknown'): ?>
<?php elseif ($data['rendered']['#markup'] == 'United States of America (USA)'): ?>
<?php print 'USA'; ?>
<?php elseif ($data['rendered']['#markup'] == 'United Kingdom (UK)'): ?>
<?php print 'UK'; ?>
<?php else: ?>
<?php print $data['rendered']['#markup']; ?>
<?php endif; ?>
<?php endforeach; ?>
As far as editing the output, this works fine. However, if the field is empty, the Label (set in views) for the field will still be printed, even though I have Hide if empty checked under No Results Behavior. If I remove my custom template, then the label is hidden when there is no value, so there must be something wrong with my template. Any ideas?