From: Sunil Pawar Date: Mon, 27 Sep 2021 16:07:55 +0000 (+0530) Subject: show processed token in greeting dropdown X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=ced905b975609147f8212e6e33e04e3730bafcff;p=civicrm-core.git show processed token in greeting dropdown replace with new token mechanism correcting syntax style fix --- diff --git a/CRM/Contact/Form/Edit/CommunicationPreferences.php b/CRM/Contact/Form/Edit/CommunicationPreferences.php index b5c9def4b5..41d7e0f169 100644 --- a/CRM/Contact/Form/Edit/CommunicationPreferences.php +++ b/CRM/Contact/Form/Edit/CommunicationPreferences.php @@ -82,8 +82,30 @@ class CRM_Contact_Form_Edit_CommunicationPreferences { 'greeting_type' => $greeting, ]; - //add addressee in Contact form + // Add addressee in Contact form. $greetingTokens = CRM_Core_PseudoConstant::greeting($filter); + + // Instead of showing smarty token with/o conditional logic in Drop down + // list, show processed token (Only in Contact Edit mode). + // Get Description of each greeting. + $greetingTokensDescription = CRM_Core_PseudoConstant::greeting($filter, 'description'); + if ($form->_contactId) { + $renderedGreetingTokens = CRM_Core_TokenSmarty::render($greetingTokens, + [ + 'contactId' => $form->_contactId, + ] + ); + foreach ($greetingTokens as $key => &$emailGreetingString) { + if ($emailGreetingString) { + $emailGreetingString = $renderedGreetingTokens[$key]; + $emailGreetingString = CRM_Core_DAO::escapeString(CRM_Utils_String::stripSpaces($emailGreetingString)); + if (!empty($greetingTokensDescription[$key])) { + // Append description to processed greeting. + $emailGreetingString .= ' ( ' . $greetingTokensDescription[$key] . ' )'; + } + } + } + } if (!empty($greetingTokens)) { $form->addElement('select', $fields['field'], $fields['label'], [ diff --git a/templates/CRM/Admin/Form/Options.tpl b/templates/CRM/Admin/Form/Options.tpl index 35a857db87..7ce72eb8ec 100644 --- a/templates/CRM/Admin/Form/Options.tpl +++ b/templates/CRM/Admin/Form/Options.tpl @@ -99,9 +99,11 @@ {$form.description.html}
{if $gName eq 'activity_type'} {ts}Description is included at the top of the activity edit and view pages for this type of activity.{/ts} + {elseif $gName eq 'email_greeting' || $gName eq 'postal_greeting' || $gName eq 'addressee'} + {ts}Description will be appended to processed greeting.{/ts} + {/if} - {/if} {/if} {if $gName eq 'participant_status'}