From: Coleman Watts Date: Thu, 7 Mar 2013 00:50:24 +0000 (-0800) Subject: Add dynamic loading of help text for custom fields CRM-12038 X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=d5a1ed7ec208e2a895e9bb81d0696f1b5386129b;p=civicrm-core.git Add dynamic loading of help text for custom fields CRM-12038 --- diff --git a/CRM/Core/Smarty/plugins/function.help.php b/CRM/Core/Smarty/plugins/function.help.php index 30070a6a22..d1c12cbb78 100644 --- a/CRM/Core/Smarty/plugins/function.help.php +++ b/CRM/Core/Smarty/plugins/function.help.php @@ -47,13 +47,6 @@ function smarty_function_help($params, &$smarty) { return; } - // Legacy support for old-style $params['text'] - // TODO: This is probably no longer used, so remove - $help = ''; - if (isset($params['text'])) { - $help = '
' . $params['text'] . '
'; - } - if (empty($params['file']) && isset($smarty->_tpl_vars['tplFile'])) { $params['file'] = $smarty->_tpl_vars['tplFile']; } diff --git a/templates/CRM/Custom/Form/CustomField.hlp b/templates/CRM/Custom/Form/CustomField.hlp new file mode 100644 index 0000000000..c6be39d277 --- /dev/null +++ b/templates/CRM/Custom/Form/CustomField.hlp @@ -0,0 +1,30 @@ +{* + +--------------------------------------------------------------------+ + | CiviCRM version 4.3 | + +--------------------------------------------------------------------+ + | Copyright CiviCRM LLC (c) 2004-2010 | + +--------------------------------------------------------------------+ + | This file is a part of CiviCRM. | + | | + | CiviCRM is free software; you can copy, modify, and distribute it | + | under the terms of the GNU Affero General Public License | + | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. | + | | + | CiviCRM is distributed in the hope that it will be useful, but | + | WITHOUT ANY WARRANTY; without even the implied warranty of | + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | + | See the GNU Affero General Public License for more details. | + | | + | You should have received a copy of the GNU Affero General Public | + | License and the CiviCRM Licensing Exception along | + | with this program; if not, contact CiviCRM LLC | + | at info[AT]civicrm[DOT]org. If you have questions about the | + | GNU Affero General Public License or the licensing of CiviCRM, | + | see the CiviCRM license FAQ at http://civicrm.org/licensing | + +--------------------------------------------------------------------+ +*} +{* Dynamically fetch the help text for a custom field *} +{htxt id=$id} + {crmAPI var='result' entity='CustomField' action='getsingle' sequential=1 id=$id} + {$result.help_post} +{/htxt} diff --git a/templates/CRM/Custom/Form/CustomField.tpl b/templates/CRM/Custom/Form/CustomField.tpl index e24b785829..e77c40e924 100644 --- a/templates/CRM/Custom/Form/CustomField.tpl +++ b/templates/CRM/Custom/Form/CustomField.tpl @@ -24,9 +24,6 @@ +--------------------------------------------------------------------+ *} {assign var="element_name" value=$element.element_name} -{if $element.help_post} - {assign var="help_post" value=$element.help_post} -{/if} {if $element.help_pre} @@ -36,7 +33,7 @@ {/if} {if $element.options_per_line != 0 } - {$form.$element_name.label}{if $element.help_post}{help id=$element_name text=$help_post}{/if} + {$form.$element_name.label}{if $element.help_post}{help id=$element.id file="CRM/Custom/Form/CustomField.hlp" title=$form.$element_name.label}{/if} {assign var="count" value="1"} @@ -67,7 +64,7 @@ {else} - + - +
{$form.$element_name.label}{if $element.help_post}{help id=$element_name text=$help_post}{/if}{$form.$element_name.label}{if $element.help_post}{help id=$element.id file="CRM/Custom/Form/CustomField.hlp" title=$form.$element_name.label}{/if} {if $element.data_type neq 'Date' OR ($element.data_type eq 'Date' AND $element.is_view eq 1)} {$form.$element_name.html}  diff --git a/templates/CRM/Custom/Form/Preview.tpl b/templates/CRM/Custom/Form/Preview.tpl index 4b2840d883..5e01810f96 100644 --- a/templates/CRM/Custom/Form/Preview.tpl +++ b/templates/CRM/Custom/Form/Preview.tpl @@ -53,7 +53,7 @@ {*assign var="element_name" value=$element.custom_group_id|cat:_|cat:$field_id|cat:_|cat:$element.name*} {assign var="element_name" value=$element.element_name}
{$form.$element_name.label}{if $element.help_post}{help id=$element_name text=$element.help_post}{/if}{$form.$element_name.label}{if $element.help_post}{help id=$element.id file="CRM/Custom/Form/CustomField.hlp" title=$form.$element_name.label}{/if} {assign var="count" value="1"} @@ -86,7 +86,7 @@ {*assign var="element_name" value=$group_id|cat:_|cat:$field_id|cat:_|cat:$element.name*} {assign var="element_name" value=$element.element_name} - +
{$form.$element_name.label}{if $element.help_post}{help id=$element_name text=$element.help_post}{/if}{$form.$element_name.label}{if $element.help_post}{help id=$element.id file="CRM/Custom/Form/CustomField.hlp" title=$form.$element_name.label}{/if} {if $element.data_type neq 'Date'} {$form.$element_name.html}