|
7 | 7 | global $pageAsset; |
8 | 8 |
|
9 | 9 | $identifier = $containerRef->identifier ?? null; |
| 10 | +$uuid = $containerRef->uuid ?? null; |
10 | 11 | $contentlets = $containerRef->contentlets ?? null; |
11 | 12 |
|
12 | | -if ($contentlets) { |
13 | | - foreach ($contentlets as $contentlet) { |
14 | | - $contentTypeVar = $contentlet->contentType ?? 'unknown'; |
15 | | - $templatePath = dirname(__DIR__) . '/content-type/' . strtolower($contentTypeVar) . '.php'; |
| 13 | +// Container attributes for UVE |
| 14 | +$containerAttrs = [ |
| 15 | + 'data-dot-object' => 'container', |
| 16 | + 'data-dot-identifier' => $identifier, |
| 17 | + 'data-dot-uuid' => $uuid, |
| 18 | + 'data-dot-accept-types' => $containerRef->acceptTypes ?? '', |
| 19 | + 'data-max-contentlets' => $containerRef->maxContentlets ?? 0 |
| 20 | +]; |
16 | 21 |
|
17 | | - if (file_exists($templatePath)) { |
18 | | - include $templatePath; |
19 | | - } else { |
20 | | - include dirname(__DIR__) . '/content-type/content-type-not-found.php'; |
21 | | - } |
| 22 | +// Build container HTML attributes string |
| 23 | +$containerHtmlAttrs = ''; |
| 24 | +foreach ($containerAttrs as $attr => $value) { |
| 25 | + if ($value !== null && $value !== '') { |
| 26 | + $containerHtmlAttrs .= ' ' . $attr . '="' . htmlspecialchars($value) . '"'; |
22 | 27 | } |
23 | | -} else { |
24 | | - echo "<!-- Container $identifier doesn't have contentlets -->"; |
25 | 28 | } |
| 29 | +?> |
| 30 | +<div<?= $containerHtmlAttrs ?>> |
| 31 | + <?php |
| 32 | + if ($contentlets) { |
| 33 | + foreach ($contentlets as $contentlet) { |
| 34 | + // Contentlet attributes for UVE |
| 35 | + $contentletAttrs = [ |
| 36 | + 'data-dot-object' => 'contentlet', |
| 37 | + 'data-dot-identifier' => $contentlet->identifier ?? '', |
| 38 | + 'data-dot-inode' => $contentlet->inode ?? '', |
| 39 | + 'data-dot-type' => $contentlet->contentType ?? '', |
| 40 | + 'data-dot-basetype' => $contentlet->baseType ?? '', |
| 41 | + 'data-dot-title' => $contentlet->title ?? '', |
| 42 | + 'data-dot-container' => json_encode([ |
| 43 | + 'identifier' => $identifier, |
| 44 | + 'uuid' => $uuid, |
| 45 | + 'acceptTypes' => $containerRef->acceptTypes ?? [], |
| 46 | + 'maxContentlets' => $containerRef->maxContentlets ?? 0, |
| 47 | + 'variantId' => $containerRef->variantId ?? null |
| 48 | + ]) |
| 49 | + ]; |
| 50 | + |
| 51 | + // Build contentlet HTML attributes string |
| 52 | + $contentletHtmlAttrs = ''; |
| 53 | + foreach ($contentletAttrs as $attr => $value) { |
| 54 | + if ($value !== null && $value !== '') { |
| 55 | + $contentletHtmlAttrs .= ' ' . $attr . '="' . htmlspecialchars($value) . '"'; |
| 56 | + } |
| 57 | + } |
| 58 | + |
| 59 | + $contentTypeVar = $contentlet->contentType ?? 'unknown'; |
| 60 | + $templatePath = dirname(__DIR__) . '/content-type/' . strtolower($contentTypeVar) . '.php'; |
| 61 | + ?> |
| 62 | + <div<?= $contentletHtmlAttrs ?>> |
| 63 | + <?php |
| 64 | + if (file_exists($templatePath)) { |
| 65 | + include $templatePath; |
| 66 | + } else { |
| 67 | + include dirname(__DIR__) . '/content-type/content-type-not-found.php'; |
| 68 | + } |
| 69 | + ?> |
| 70 | + </div> |
| 71 | + <?php |
| 72 | + } |
| 73 | + } else { |
| 74 | + echo "<!-- Container $identifier doesn't have contentlets -->"; |
| 75 | + } |
| 76 | + ?> |
| 77 | +</div> |
0 commit comments