We would like to rearrange the output of custom fields on the basic contact view page (in Drupal, /civicrm/contact/view?cid=NNNN&reset=1) in CiviCRM 4.5 on Drupal 7. Specifically, since this is a university student organization, we have a custom field called "Class Year" (simple text, field id 31, in custom data group 1 "Enrollment information") that we would like to display in the main title, after the display name. Thus, the page headline would say Joan Smith 2017 instead of the default Joan Smith.
The template to override we found easily enough in /sites/all/modules/civicrm/templates/CRM/Contact/Page/Inline/ContactName.tpl
. The question is then what is the template variable for this custom field?
We could not locate this in the documentation, and all the forum threads that come up seem to be about customizing event or contribution pages, not the contact page itself.
With debugging on, adding the &smartydebug=1
parameter to the query string on the record returns this value for {$viewCustomData}:
Array (3)
1 => Array (1)
1421 => Array (7)
title => "Enrollment information"
name => "enrollment_information"
help_pre => ""
help_post => ""
collapse_display => "0"
collapse_adv_display => null
fields => Array (11)
31 => Array (5)
field_title => "Class Year"
field_type => "Text"
field_data_type => "Int"
field_value => "2017"
options_per_line => null
2 => Array (5)
[snipped]
Based on this and examples of template overrides elsewhere, we have made a number guesses, among them
{$custom_value_31}
{$profileFields_1.custom_31}
{$viewCustomData.1.fields.31}
{$viewCustomData.1.1421.fields.31}
but they have all been fruitless.
Google finds very few forum threads at all that even mention {$viewCustomData}, so any enlightenment is greatly appreciated.