1

This is not a duplicate of Is it possible to change the Mailing label format?

While printing Mailing Labels, we've found that Addressee Tokens don't work as expected when "Merge labels for contacts with the same address" is ticked.

Mean, if one wants to get "Mr & Mrs Smith", {addressee} token should be used at civicrm/admin/setting/preferences/address?reset=1; we've tried to add "contact.formal_title", but it doesn't get merged properly, only first value is printed, so it looks like:

 "Mr Smith Title
Mr A & Mrs B Smith " 

instead of

Mr Smith Title  A & Mrs Smith Title B Smith

There is a mergeSameAddress function at \civicrm\CRM\Core\BAO\Address.php which works with &$rows parameter, but there is no "formal_title" in a $row according to print_r:

  [contact_type] => Individual
            [display_name] => H S W
            [do_not_mail] => 0
            [first_name] => H S
            [last_name] => W
            [prefix_id] => 
            [is_deceased] => 0
            [addressee_id] => 1
            [addressee_display] => H S W
            [addressee_custom] => 
            [address_id] => 20144
            [street_address] => 111
            [supplemental_address_1] => 111
            [supplemental_address_2] => 
            [city] => 
            [postal_code_suffix] => 
            [postal_code] => 111
            [address_name] => 
            [county_id] => 
            [state_province_id] => 
            [country_id] => 1226
            [individual_prefix] => 
            [addressee] => H S W
            [county] => 
            [state_province_name] => 
            [state_province] => 
            [country] => 111

What would be a proper way to add formal_title as a part of a merged address value (assuming appending formal_title to a first name)? Currently, Prefix works as desired, but it exists in a $rows, so can be easily retrieved. Not sure why formal_title is not a part of this and it's not clear, where $rows data is came from.

UPDATE

Desired result has been achieved by modifying two core files:

  1. civicrm/CRM/Core/BAO/Address.php

line 1059

'formal_title' => $rows[$rowID]['formal_title'],

line 1095

replace

$family = trim(implode(" & ", array_keys($first_names)) . " " . $last_name);

to

$family = trim(implode(" & ", array_keys($first_names)));

  1. civicrm/CRM/Contact/Form/Task/Label.php line 167

$returnProperties['formal_title'] = 1;

Just curious, how to make it according to best practices of CiviCRM development.

1

1 Answer 1

3

The answer is already here. According to a tiny mention at the bottom of http://wiki.civicrm.org/confluence/display/CRMDOC/Directories page, it is possible (and, more important, it works!) to copy modified core files to Custom PHP Path Directory (at civicrm/admin/setting/path?reset=1) , preserving original files/folders structure, so next time CiviCRM gets security updates, changes should be kept (unless original file / function major changes).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.