render with unique ids

This commit is contained in:
buttle 2021-04-03 18:56:54 +02:00
parent d25de5493e
commit 414217e069
2 changed files with 5 additions and 7 deletions

View File

@ -70,14 +70,12 @@ class PanoramaViewer extends AbstractBlockLayout
}
$urls = [];
$pannellum_ids = [];
$id = 1;
static $id = 0;
foreach ($attachments as $attachment)
{
foreach($attachment->item()->media() as $media)
{
$id = $id +1;
array_push($pannellum_ids, "pv-{$id}");
$mediaType = $media->mediaType();
$mediaRenderer = $media->renderer();
if (strpos($mediaType, 'image/') !== false) {
@ -91,7 +89,7 @@ class PanoramaViewer extends AbstractBlockLayout
'title' => $block->dataValue('title'),
'height' => $block->dataValue('height'),
'urls' => $urls,
'pannellum_ids' => $pannellum_ids,
'id' => 'pv-' . ++$id,
]);
}
}

View File

@ -17,12 +17,12 @@
</style>
<div class="pannellum">
<div id="<?= $pannellum_ids[0] ?>" class="panorama-viewer"></div>
<div id="<?= $id ?>" class="panorama-viewer"></div>
</div>
<script>
pannellum.viewer("<?= $pannellum_ids[0] ?>", {
pannellum.viewer("<?= $id ?>", {
type: "<?= $panorama_type ?>",
autoLoad: true,
panorama: "<?= $urls[0]; ?>",