Ensure communityMessages is assigned to the template.
authorEileen McNaughton <emcnaughton@wikimedia.org>
Sun, 31 Oct 2021 21:38:57 +0000 (10:38 +1300)
committerEileen McNaughton <emcnaughton@wikimedia.org>
Sun, 31 Oct 2021 22:11:50 +0000 (11:11 +1300)
This is a minor code simplification & ensures the parameter is set rather than
handling it not being set at the template level

CRM/Contact/Page/DashBoard.php
templates/CRM/Contact/Page/DashBoardDashlet.tpl

index 48ea3ac19cecaad86b62c767605d7fe3dc895d3d..4d6a935a8eaefa4d0c77703decd841c5c9542b9d 100644 (file)
@@ -36,13 +36,7 @@ class CRM_Contact_Page_DashBoard extends CRM_Core_Page {
       $this->assign('hookContentPlacement', $contentPlacement);
     }
 
-    $communityMessages = CRM_Core_CommunityMessages::create();
-    if ($communityMessages->isEnabled()) {
-      $message = $communityMessages->pick();
-      if ($message) {
-        $this->assign('communityMessages', $communityMessages->evalMarkup($message['markup']));
-      }
-    }
+    $this->assign('communityMessages', $this->getCommunityMessageOutput());
 
     $loader = Civi::service('angularjs.loader');
     $loader->addModules('crmDashboard');
@@ -95,4 +89,20 @@ class CRM_Contact_Page_DashBoard extends CRM_Core_Page {
     ];
   }
 
+  /**
+   * Get community message output.
+   *
+   * @return string
+   */
+  protected function getCommunityMessageOutput(): string {
+    $communityMessages = CRM_Core_CommunityMessages::create();
+    if ($communityMessages->isEnabled()) {
+      $message = $communityMessages->pick();
+      if ($message) {
+        return $communityMessages->evalMarkup($message['markup']);
+      }
+    }
+    return '';
+  }
+
 }
index aaf2ab62b08ee7313788dd2ee3e1da1b3c55bdf9..ac2ed7af3f23658b4a8e299ecfc7ea9bdd472c5b 100644 (file)
@@ -9,7 +9,7 @@
 *}
 {include file="CRM/common/chart.tpl"}
 {* Alerts for critical configuration settings. *}
-{$communityMessages|default:''}
+{$communityMessages}
 <div class="clear"></div>
 <div class="crm-block crm-content-block">