1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-01 20:30:39 +02:00

Issue #5422 Calling e107::schema() multiple times with json data no longer overwrites existing data and will render all of the items.

This commit is contained in:
camer0n
2025-06-04 15:27:43 -07:00
parent 3a44d02f38
commit d3a9abb9b8
2 changed files with 22 additions and 5 deletions

View File

@@ -190,7 +190,7 @@ unset($e_headers);
/** @experimental - subject to change at any time */ /** @experimental - subject to change at any time */
if($schema = e107::schema()) if($schema = e107::schema())
{ {
echo '<script type="application/ld+json">'.$schema."</script>\n"; echo $schema;
} }
unset($schema); unset($schema);

View File

@@ -4559,21 +4559,38 @@ class e107
/** /**
* Getter/Setter for schema. eg. Google structured data etc. * Getter/Setter for schema. eg. Google structured data etc.
* @param string $json * @param string $json
* @return string|bool|null * @return string|null
*/ */
public static function schema($json = null) public static function schema($json = null)
{ {
static $currentSchema = [];
if(empty($json)) if(empty($json))
{ {
return self::getRegistry('core/e107/schema', false); if(empty($currentSchema))
{
return '';
}
$output = '';
foreach($currentSchema as $schema)
{
if(!empty($schema))
{
$output .= '<script type="application/ld+json">' . $schema . "</script>\n";
}
}
return $output;
} }
return self::setRegistry('core/e107/schema',$json); $currentSchema[] = $json;
return self::setRegistry('core/e107/schema', $currentSchema);
} }
/** /**
* Retrieve error page handler. * Retrieve error page handler.
* *