<?php /** * Copyright © Magefan (support@magefan.com). All rights reserved. * Please visit Magefan.com for license details (https://magefan.com/end-user-license-agreement). */ ?> <?php /** * Blog sidebar posts list template * * @var $block \Magefan\Blog\Block\Post\PostList\AbstractList */ ?> <?php $_postCollection = $block->getPostCollection(); $width = (int)$block->getBlockImageWidth() ?: 300; $height = (int)$block->getBlockImageheight() ?: 200; $imageHelper = $this->helper(\Magefan\Blog\Helper\Image::class); ?> <?php if ($_postCollection->count()) { ?> <div class="block-<?= $escaper->escapeHtml(str_replace('_', '-', $block->getWidgetKey())) ?> block-list-posts mb-10" ><div class="title text-xl md:text-2xl font-semibold py-2"><?= $escaper->escapeHtml(__($block->getBlockTitle() ?: 'Recent Posts')) ?></div><div class="block-content flex flex-col gap-6 mt-3"><?php foreach ($_postCollection as $_post) { $_postUrl = $escaper->escapeUrl($_post->getPostUrl()); $_postName = $escaper->escapeHtml($_post->getTitle()); ?> <div class="item flex gap-4"><?php if ($block->getDisplayImage()) { ?> <?php $featuredImage = $_post->getFeaturedListImage() ?: $_post->getFeaturedImage(); $featuredImgAlt = $_post->getData('featured_list_img_alt') ?: $_post->getData('featured_img_alt'); $featuredImgAlt = $featuredImgAlt ?: $_postName; ?> <div class="post-image flex-grow-0 flex-shrink-0 self-start w-4/12"><a class="post-item-link" title="<?= $_postName ?>" href="<?= $_postUrl ?>"><?php $featuredImageUrl = $featuredImage ? $imageHelper->init($_post->getFeaturedListImg() ?: $_post->getFeaturedImg())->resize($width, $height) : $this->getViewFileUrl('Magefan_Blog::images/default-no-image.png'); ?> <img data-width-amp="<?= $width ?>" data-height-amp="<?= $height ?>" layout="responsive" src="<?= $escaper->escapeUrl($featuredImageUrl) ?>" alt="<?= $escaper->escapeHtml($featuredImgAlt) ?>" /></a></div><?php } ?> <div class="post-info flex-grow-1"><a class="post-item-link font-medium hover:text-red duration-300" title="<?= $_postName ?>" href="<?= $_postUrl ?>"><?= $_postName ?></a> <?php if ($block->getDisplayImage() && $_post->isPublishDateEnabled()) { ?> <div class="post-item-date text-gray-400"><span class="value"><?= $escaper->escapeHtml($_post->getPublishDate()) ?></span></div><?php } ?></div></div><?php } ?></div></div><?php } ?>