From c58563b32f3d5ad423a5e2933e938de50bd09931 Mon Sep 17 00:00:00 2001 From: Rich Lott / Artful Robot Date: Thu, 27 Jul 2023 16:03:27 +0100 Subject: [PATCH] standalone: move breadcrumb rendering into template --- CRM/Core/Invoke.php | 2 +- CRM/Utils/System/Standalone.php | 22 +++++++++------------- templates/CRM/common/standalone.tpl | 11 ++++------- 3 files changed, 14 insertions(+), 21 deletions(-) diff --git a/CRM/Core/Invoke.php b/CRM/Core/Invoke.php index 51b2d0cb15..230ceb7c14 100644 --- a/CRM/Core/Invoke.php +++ b/CRM/Core/Invoke.php @@ -249,7 +249,7 @@ class CRM_Core_Invoke { CRM_Utils_System::setTitle($item['title']); } - if (isset($item['breadcrumb']) && !isset($item['is_public'])) { + if (isset($item['breadcrumb']) && empty($item['is_public'])) { CRM_Utils_System::appendBreadCrumb($item['breadcrumb']); } diff --git a/CRM/Utils/System/Standalone.php b/CRM/Utils/System/Standalone.php index 3b33669a01..f560e2456f 100644 --- a/CRM/Utils/System/Standalone.php +++ b/CRM/Utils/System/Standalone.php @@ -108,7 +108,11 @@ class CRM_Utils_System_Standalone extends CRM_Utils_System_Base { * @inheritDoc */ public function appendBreadCrumb($breadcrumbs) { - \Civi::$statics[__CLASS__]['breadcrumb'][] = $breadcrumbs; + if (!isset(\Civi::$statics[__CLASS__]['breadcrumb'])) { + \Civi::$statics[__CLASS__]['breadcrumb'] = []; + } + \Civi::$statics[__CLASS__]['breadcrumb'] += $breadcrumbs; + CRM_Core_Smarty::singleton()->assign('breadcrumb', \Civi::$statics[__CLASS__]['breadcrumb']); } /** @@ -116,6 +120,7 @@ class CRM_Utils_System_Standalone extends CRM_Utils_System_Base { */ public function resetBreadCrumb() { \Civi::$statics[__CLASS__]['breadcrumb'] = []; + CRM_Core_Smarty::singleton()->assign('breadcrumb', NULL); } /** @@ -123,6 +128,9 @@ class CRM_Utils_System_Standalone extends CRM_Utils_System_Base { */ public function addHTMLHead($header) { $template = CRM_Core_Smarty::singleton(); + // Smarty's append function does not check for the existence of the var before appending to it. + // So this prevents a stupid notice error: + $template->ensureVariablesAreAssigned(['pageHTMLHead']); $template->append('pageHTMLHead', $header); return; } @@ -261,18 +269,6 @@ class CRM_Utils_System_Standalone extends CRM_Utils_System_Base { echo implode('', $smarty->_tpl_vars['pageHTMLHead']); } - // Show the breadcrumb - if (!empty(\Civi::$statics[__CLASS__]['breadcrumb'])) { - print ''; - } - // @todo Add variables from the body tag? (for Shoreditch) print $content; return NULL; diff --git a/templates/CRM/common/standalone.tpl b/templates/CRM/common/standalone.tpl index cfff247759..154adfa2f8 100644 --- a/templates/CRM/common/standalone.tpl +++ b/templates/CRM/common/standalone.tpl @@ -24,21 +24,18 @@ {$docTitle} - {if $config->debug} {include file="CRM/common/debug.tpl"} {/if}
{if $breadcrumb} - + {/if} {if $pageTitle} -- 2.25.1