Allow help text to be overridden from an .extra.hlp file
authorColeman Watts <coleman@civicrm.org>
Sun, 20 Jan 2019 21:49:05 +0000 (16:49 -0500)
committerColeman Watts <coleman@civicrm.org>
Mon, 21 Jan 2019 14:16:19 +0000 (09:16 -0500)
CRM/Core/Page/Inline/Help.php
CRM/Core/Smarty/plugins/block.htxt.php

index 23f9cf121209c892983d39f2740c20e75c5bd769..24938836b0d400f5a23b81560f28c6d97d3dde25 100644 (file)
@@ -49,14 +49,19 @@ class CRM_Core_Page_Inline_Help {
       }
       $smarty->assign('params', $args);
 
+      $output = $smarty->fetch($file);
       $extraoutput = '';
       if ($smarty->template_exists($additionalTPLFile)) {
         //@todo hook has been put here as a conservative approach
         // but probably should always run. It doesn't run otherwise because of the exit
         CRM_Utils_Hook::pageRun($this);
         $extraoutput .= trim($smarty->fetch($additionalTPLFile));
+        // Allow override param to replace default text e.g. {hlp id='foo' override=1}
+        if ($smarty->get_template_vars('override_help_text')) {
+          $output = '';
+        }
       }
-      exit($smarty->fetch($file) . $extraoutput);
+      exit($output . $extraoutput);
     }
   }
 
index f4ae2ea53d9bb6d96b74ddbc4ca8cc38a8e6779d..be78a1d86f05112005d3bba54d054d9b34b39b19 100644 (file)
@@ -48,8 +48,8 @@
  *   the string, translated by gettext
  */
 function smarty_block_htxt($params, $text, &$smarty) {
-  $id = $params['id'];
-  if ($id == $smarty->_tpl_vars['id']) {
+  if ($params['id'] == $smarty->_tpl_vars['id']) {
+    $smarty->assign('override_help_text', !empty($params['override']));
     return $text;
   }
   else {