89 lines
3.7 KiB
PHTML
89 lines
3.7 KiB
PHTML
<?php
|
|
|
|
/**
|
|
* @var \Esun\Homepage\Block\NewsRoom $block
|
|
* @var \Magento\Framework\Escaper $escaper
|
|
*/
|
|
|
|
$items = $block->getItems();
|
|
if (!$items) {
|
|
return;
|
|
}
|
|
|
|
$pages = array_chunk($items, 4);
|
|
$hasNavigation = count($pages) > 1;
|
|
?>
|
|
<section class="esun-news-room" aria-labelledby="esun-news-room-title">
|
|
<div class="esun-news-room__heading">
|
|
<h2 class="typo-section-title" id="esun-news-room-title">
|
|
<?= $escaper->escapeHtml(__('News Room')) ?>
|
|
</h2>
|
|
|
|
<?php if ($hasNavigation): ?>
|
|
<div class="esun-news-room__navigation">
|
|
<button class="esun-news-room__previous"
|
|
type="button"
|
|
aria-label="<?= $escaper->escapeHtmlAttr(__('Previous')) ?>">
|
|
<span class="arrow-left" aria-hidden="true"></span>
|
|
</button>
|
|
<button class="esun-news-room__next"
|
|
type="button"
|
|
aria-label="<?= $escaper->escapeHtmlAttr(__('Next')) ?>">
|
|
<span class="arrow-right" aria-hidden="true"></span>
|
|
</button>
|
|
</div>
|
|
<?php endif; ?>
|
|
</div>
|
|
|
|
<div class="esun-news-room__slider swiper-container"
|
|
data-role="esun-news-room-slider"
|
|
data-has-navigation="<?= $hasNavigation ? 'true' : 'false' ?>">
|
|
<div class="swiper-wrapper">
|
|
<?php foreach ($pages as $pageItems): ?>
|
|
<div class="esun-news-room__page swiper-slide">
|
|
<div class="esun-news-room__grid">
|
|
<?php foreach ($pageItems as $item): ?>
|
|
<article class="esun-news-room__slide">
|
|
<a class="esun-news-room__card" href="<?= $escaper->escapeUrl($item['url']) ?>">
|
|
<span class="esun-news-room__image-wrap">
|
|
<img class="esun-news-room__image"
|
|
src="<?= $escaper->escapeUrl($item['image_url']) ?>"
|
|
alt="<?= $escaper->escapeHtmlAttr($item['title']) ?>">
|
|
</span>
|
|
<span class="esun-news-room__meta">
|
|
<?php if ($item['publish_date']): ?>
|
|
<time datetime="<?= $escaper->escapeHtmlAttr($item['publish_date_iso']) ?>">
|
|
<?= $escaper->escapeHtml($item['publish_date']) ?>
|
|
</time>
|
|
<?php endif; ?>
|
|
<?php if ($item['tag_name']): ?>
|
|
<span class="esun-news-room__category">
|
|
<?= $escaper->escapeHtml($item['tag_name']) ?>
|
|
</span>
|
|
<?php endif; ?>
|
|
</span>
|
|
<span class="esun-news-room__title">
|
|
<?= $escaper->escapeHtml($item['title']) ?>
|
|
</span>
|
|
</a>
|
|
</article>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
|
|
<?php if ($hasNavigation): ?>
|
|
<div class="esun-news-room__pagination swiper-pagination"></div>
|
|
<?php endif; ?>
|
|
</div>
|
|
</section>
|
|
|
|
<script type="text/x-magento-init">
|
|
{
|
|
"[data-role=esun-news-room-slider]": {
|
|
"Esun_Homepage/js/news-room": {}
|
|
}
|
|
}
|
|
</script>
|