Skip to content

Commit

Permalink
Add option to open custom URL links in a new tab (#2106)
Browse files Browse the repository at this point in the history
  • Loading branch information
jimsafley authored Oct 26, 2023
1 parent 35710e7 commit 7680b56
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions application/src/Site/Navigation/Link/Url.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ public function toZend(array $data, SiteRepresentation $site)
return [
'type' => 'uri',
'uri' => $data['url'],
'target' => (isset($data['target_blank']) && $data['target_blank']) ? '_blank' : null,

];
}

Expand All @@ -48,6 +50,7 @@ public function toJstree(array $data, SiteRepresentation $site)
return [
'label' => $data['label'],
'url' => $data['url'],
'target_blank' => $data['target_blank'] ?? false,
];
}
}
8 changes: 8 additions & 0 deletions application/view/common/navigation-link-form/url.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,15 @@ $translate = $this->plugin('translate');
$escape = $this->plugin('escapeHtml');
$label = isset($data['label']) && '' !== trim($data['label']) ? $data['label'] : null;
$url = isset($data['url']) && '' !== trim($data['url']) ? $data['url'] : null;
$targetBlank = isset($data['target_blank']) ? (bool) $data['target_blank'] : false;
?>
<label><?php echo $translate('Type'); ?> <input type="text" value="<?php echo $escape($translate($link->getName())); ?>" disabled></label>
<label class="required"><?php echo $translate('Label'); ?> <input type="text" data-name="label" value="<?php echo $escape($label); ?>" required></label>
<label class="required"><?php echo $translate('URL'); ?> <input type="text" data-name="url" value="<?php echo $escape($url); ?>" required></label>
<label>
<?php echo $translate('Open in new tab'); ?>
<select data-name="target_blank">
<option value="0"<?php echo $targetBlank ? '' : ' selected'; ?>><?php echo $translate('No'); ?></option>
<option value="1"<?php echo $targetBlank ? 'selected' : ''; ?>><?php echo $translate('Yes'); ?></option>
</select>
</label>

0 comments on commit 7680b56

Please sign in to comment.