Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check if downloadURL isset before rendering #4197

Merged
merged 1 commit into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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