Override title with field label instead of key inside a views contextual filter I have a soccer team Drupal 7 site where I keep track of the players using a user role.  I have a view of the players which grids their profile pics and I'm very happy with it.  It's URL is /players

Now I want to divide the players into separate groups.  My first stab at this was to add a user_program field onto the User content type.  I added this field of type List(text), and gave it keys/values like:
youth_competitive_program|Youth Competitive Program
primary_competitive_programe|Primary Competitive Program

I then added a Contextual Filter so that I have /players/youth_competitive_program and such.  Works very well.  Except:  when I tell those views to override the title using %1 I get the key instead of the value.  What I really want is my human readable value up there, not the key.
edit your Contextual Filter check Specify validation criteria in Validator check PHP code and enter following:

if ($argument == 'youth_competitive_program') {
  $handler-&gt;options['title'] = 'Youth Competitive Program';
  return true;
} else if ($argument == 'primary_competitive_programe') {
  $handler-&gt;options['title'] = 'Primary Competitive Program';
  return true;
}
return false;


there is another similar way:

if (!empty($argument)) {
  $handler-&gt;options['title'] = t($argument);
  return true;
}

return false;


and translate them, so if you add more option to your user_program fields, this code will work better.

but there is another option yet:

$field = field_info_field('field_user_program');
if (array_key_exists($argument, $field['settings']['allowed_values'])) {
  $handler-&gt;options['title'] = $field['settings']['allowed_values'][$argument];
  return true;
}
return false;


I will select the last way