From e950090330fdae409a1c38243cf7fa19dbd9b492 Mon Sep 17 00:00:00 2001 From: Daniel Gading Date: Tue, 25 Jun 2024 11:07:38 -0400 Subject: [PATCH] Check if downloadURL isset before rendering (#4197) --- modules/metastore/metastore.theme.inc | 3 ++- modules/metastore/templates/node--data.html.twig | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/metastore/metastore.theme.inc b/modules/metastore/metastore.theme.inc index 29b65c45b6..43e90e2316 100644 --- a/modules/metastore/metastore.theme.inc +++ b/modules/metastore/metastore.theme.inc @@ -15,6 +15,7 @@ function metastore_preprocess_node__data(&$variables) { $json = $variables['node']->get('field_json_metadata')->value; $rows = []; $metadata = json_decode($json); + $variables['metastore'] = $metadata; if (property_exists($metadata, 'description')) { $variables['dataset']['description'] = $metadata->description; } @@ -98,7 +99,7 @@ function metastore_preprocess_node__data(&$variables) { } } // Fallback to display file path for link title. - if ($rows['downloadURL'] && !property_exists($d, 'title')) { + if (isset($rows['downloadURL']) && !property_exists($d, 'title')) { $rows['title'] = $rows['downloadURL']; } $variables['dataset']['distributions'][] = $rows; diff --git a/modules/metastore/templates/node--data.html.twig b/modules/metastore/templates/node--data.html.twig index 66d9c7f506..12367dc791 100644 --- a/modules/metastore/templates/node--data.html.twig +++ b/modules/metastore/templates/node--data.html.twig @@ -4,6 +4,7 @@ * Default theme implementation to display a node. * * Available variables: + * metastore: The field_json_metadata decoded JSON object. * dataset: The information from the dataset metadata store. * - dataset.medata_table will return a table with the caption "Additional * metadata", that includes all the information in a single table, except