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' => [ 'DefaultSettings' => [
'SketchfabBlockForm' => [ 'SketchfabBlockForm' => [
'title' => '', 'title' => '',
'renderSourceLink' => true,
'width' => 600, 'width' => 600,
'ratio' => '2', 'ratio' => '2',
'wrapStyle' => 'overflow-y: hidden;display: flex;flex-direction: column;justify-content: center;', '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][title]' => $data['title'],
'o:block[__blockIndex__][o:data][width]' => $data['width'], 'o:block[__blockIndex__][o:data][width]' => $data['width'],
'o:block[__blockIndex__][o:data][ratio]' => $data['ratio'], 'o:block[__blockIndex__][o:data][ratio]' => $data['ratio'],
'o:block[__blockIndex__][o:data][renderSourceLink]' => $data['renderSourceLink'],
]); ]);
$form->prepare(); $form->prepare();
@ -78,7 +79,9 @@ class Sketchfab extends AbstractBlockLayout
//$height = $width / $block->dataValue('ratio'); //$height = $width / $block->dataValue('ratio');
$height = $width / 1.333; $height = $width / 1.333;
return $view->partial('common/block-layout/sketchfab', [ 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, 'width' => $width,
'height' => $height, 'height' => $height,
'sketchfab_iframe' => $media->mediaData()['html'], 'sketchfab_iframe' => $media->mediaData()['html'],

View File

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