From d3a9abb9b81e0ee32175bf574d81af23b600ee29 Mon Sep 17 00:00:00 2001 From: camer0n Date: Wed, 4 Jun 2025 15:27:43 -0700 Subject: [PATCH] Issue #5422 Calling e107::schema() multiple times with json data no longer overwrites existing data and will render all of the items. --- e107_core/templates/header_default.php | 2 +- e107_handlers/e107_class.php | 25 +++++++++++++++++++++---- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/e107_core/templates/header_default.php b/e107_core/templates/header_default.php index ef8efaea7..93a7462c6 100644 --- a/e107_core/templates/header_default.php +++ b/e107_core/templates/header_default.php @@ -190,7 +190,7 @@ unset($e_headers); /** @experimental - subject to change at any time */ if($schema = e107::schema()) { - echo '\n"; + echo $schema; } unset($schema); diff --git a/e107_handlers/e107_class.php b/e107_handlers/e107_class.php index 22d83888c..6f8d7ead3 100644 --- a/e107_handlers/e107_class.php +++ b/e107_handlers/e107_class.php @@ -4559,21 +4559,38 @@ class e107 /** * Getter/Setter for schema. eg. Google structured data etc. * @param string $json - * @return string|bool|null + * @return string|null */ public static function schema($json = null) { + + static $currentSchema = []; + if(empty($json)) { - return self::getRegistry('core/e107/schema', false); + if(empty($currentSchema)) + { + return ''; + } + + $output = ''; + foreach($currentSchema as $schema) + { + if(!empty($schema)) + { + $output .= '\n"; + } + } + + return $output; } - return self::setRegistry('core/e107/schema',$json); + $currentSchema[] = $json; + return self::setRegistry('core/e107/schema', $currentSchema); } - /** * Retrieve error page handler. *