Skip to content

Commit

Permalink
Fix channel encoding/error handling. (#2687)
Browse files Browse the repository at this point in the history
  • Loading branch information
demiankatz authored Jan 27, 2023
1 parent 38e6924 commit 1909476
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion themes/bootstrap3/js/channels.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
/*global getUrlRoot, VuFind */
VuFind.register('channels', function Channels() {
function addLinkButtons(elem) {
var links = JSON.parse(elem.dataset.linkJson);
var links;
try {
links = JSON.parse(elem.dataset.linkJson);
} catch (e) {
console.error("Error parsing " + elem.dataset.linkJson);
return;
}
if (links.length === 0) {
return;
}
Expand Down
2 changes: 1 addition & 1 deletion themes/bootstrap3/templates/channels/channelList.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
</div>
<?php endif; ?>

<div id="<?=$channelID ?>" class="channel" data-group="<?=$groupId ?>" data-link-json='<?=empty($channel['links']) ? '[]' : json_encode($channel['links']) ?>'>
<div id="<?=$channelID ?>" class="channel" data-group="<?=$groupId ?>" data-link-json='<?=empty($channel['links']) ? '[]' : json_encode($channel['links'], JSON_HEX_APOS) ?>'>
<!-- Wrapper for slides -->
<?php foreach ($channel['contents'] as $index => $item): ?>
<?php $url = empty($item['routeDetails']) ? $this->recordLinker()->getUrl("{$item['source']}|{$item['id']}") : $this->url($item['routeDetails']['route'], $item['routeDetails']['params']); ?>
Expand Down

0 comments on commit 1909476

Please sign in to comment.