How do I override a fields output in a Views template? I have a field, foo, set to "Exclude from display", and output later in a "Global: Custom text".

I need to control the rendering of this field based on a different value on the same node.
I thought I could just implement a template file like:

function THEME_views_view_field__VIEWNAME__DISPLAYNAME__FIELDNAME($view, $field, $row) {
  $output = isset($bar) ? $foo : $baz;
  return $output;
}


But as soon as I add this function to my template.php file, I loose all output instead. No matter what I return, I get nothing. I tried trivial things like

return 'AAAAA';


to no avail. I'm probably doing something very simple wrong, but looking at my own previous attempts to do similar things in the same template file, I can't see what's wrong. Yes, I've cleared the cache numerous times.
I don't know if this is the answer you wanted, but I template the individual fields by templating the custom:global, and accessing the individual pieces through the $view object.