Skip to content

Commit

Permalink
Check if downloadURL isset before rendering (#4197)
Browse files Browse the repository at this point in the history
  • Loading branch information
dgading committed Jun 25, 2024
1 parent c46d0ca commit e950090
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
3 changes: 2 additions & 1 deletion modules/metastore/metastore.theme.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions modules/metastore/templates/node--data.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e950090

Please sign in to comment.