renders source link and subtitle

This commit is contained in:
buttle 2021-05-31 20:09:46 +02:00
parent 6615daba09
commit f4573421dc
4 changed files with 34 additions and 8 deletions

View File

@ -21,6 +21,7 @@ return [
'Render3DBlockForm' => [
'model_type' => 'gltf',
'title' => '',
'renderSourceLink' => true,
'width' => 600,
'wrapStyle' => 'overflow-y: hidden;display: flex;flex-direction: column;justify-content: center;',
//'imgStyle' => '',

View File

@ -20,14 +20,6 @@ class Render3DBlockForm extends Form
],
]);
$this->add([
'name' => 'o:block[__blockIndex__][o:data][title]',
'type' => Element\Text::class,
'options' => [
'label' => 'Title (option)',
]
]);
$this->add([
'name' => 'o:block[__blockIndex__][o:data][width]',
'type' => Element\Number::class,
@ -39,5 +31,23 @@ class Render3DBlockForm 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 Render3D extends AbstractBlockLayout
'o:block[__blockIndex__][o:data][model_type]' => $data['model_type'],
'o:block[__blockIndex__][o:data][title]' => $data['title'],
'o:block[__blockIndex__][o:data][width]' => $data['width'],
'o:block[__blockIndex__][o:data][renderSourceLink]' => $data['renderSourceLink'],
]);
$form->prepare();
@ -94,6 +95,8 @@ class Render3D extends AbstractBlockLayout
'title' => $block->dataValue('title'),
'width' => $width,
'height' => $height,
'item_url' => $attachments[0]->item()->url(),
'renderSourceLink' => $block->dataValue('renderSourceLink'),
'urls' => $urls,
'id' => 'v3d-' . ++$id,
'mediaTypes' => $media_types,

View File

@ -22,7 +22,13 @@ console.log(<?= json_encode($urls, JSON_UNESCAPED_SLASHES) ?>)
}
</style>
<div class="3d-model-wrap">
<?php if ($renderSourceLink) { ?>
<div class="source-link">
<a href="<?= $item_url ?>">Source</a>
</div>
<?php } ?>
<?php if ($model_type == "gltf") { ?>
<div id="<?= $id ?>">
@ -98,6 +104,12 @@ console.log(<?= json_encode($urls, JSON_UNESCAPED_SLASHES) ?>)
</div>
<?php } ?>
<?php if ($title) { ?>
<div class="item_title">
<?= $title ?>
</div>
<?php } ?>
</div>
<script>