adds item source link and item subtitile

This commit is contained in:
buttle 2021-06-27 12:38:19 +02:00
parent 191087a1e4
commit f633eeb529
4 changed files with 35 additions and 8 deletions

View File

@ -30,6 +30,7 @@ return [
'DefaultSettings' => [
'SketchfabBlockForm' => [
'title' => '',
'renderSourceLink' => true,
'width' => 600,
'ratio' => '2',
'wrapStyle' => 'overflow-y: hidden;display: flex;flex-direction: column;justify-content: center;',

View File

@ -29,5 +29,24 @@ class SketchfabBlockForm extends Form
],
]);
$this->add([
'type' => Element\Checkbox::class,
'name' => 'o:block[__blockIndex__][o:data][renderSourceLink]',
'options' => [
'label' => 'Display a link to the item',
//'use_hidden_element' => true,
'checked_value' => true,
'unchecked_value' => false,
],
]);
$this->add([
'name' => 'o:block[__blockIndex__][o:data][title]',
'type' => Element\Text::class,
'options' => [
'label' => 'Sub-title',
]
]);
}
}

View File

@ -50,6 +50,7 @@ class Sketchfab extends AbstractBlockLayout
'o:block[__blockIndex__][o:data][title]' => $data['title'],
'o:block[__blockIndex__][o:data][width]' => $data['width'],
'o:block[__blockIndex__][o:data][ratio]' => $data['ratio'],
'o:block[__blockIndex__][o:data][renderSourceLink]' => $data['renderSourceLink'],
]);
$form->prepare();
@ -78,7 +79,9 @@ class Sketchfab extends AbstractBlockLayout
//$height = $width / $block->dataValue('ratio');
$height = $width / 1.333;
return $view->partial('common/block-layout/sketchfab', [
'title' => false,
'title' => $block->dataValue('title'),
'renderSourceLink' => $block->dataValue('renderSourceLink'),
'item_url' => $attachments[0]->item()->url(),
'width' => $width,
'height' => $height,
'sketchfab_iframe' => $media->mediaData()['html'],

View File

@ -1,15 +1,19 @@
<div class="sketchfab-wrap" style="position:relative;">
<?php
if ($title !== false && $title !== "") {
$title = sprintf('<p id="sketchfab-title">%s</p>', $title);
} else {
$title = false;
}
?>
<?php if ($renderSourceLink) { ?>
<div class="source-link">
<a href="<?= $item_url ?>">Source</a>
</div>
<?php } ?>
<?= $sketchfab_iframe ?>
<?php if ($title) { ?>
<div class="item_title">
<?= $title ?>
</div>
<?php } ?>
</div>