<?php
    $_post = $block->getPost();
    $_postUrl = $block->escapeUrl($_post->getPostUrl());
    $_postName = $block->escapeHtml($_post->getTitle());
	$featuredImage = $_post->getFeaturedListImage() ?: $_post->getFeaturedImage();
?>
<?php if ($block->displayPosts()) { ?>
    <?php $_postCollection = $block->getPostCollection(); ?>
    <?php if ($_postCollection->count()) { 
		$helper = $this->helper('Rokanthemes\RokanBase\Helper\Data');
		$enable = $helper->getConfigData('mfblog/general/enable_frontend');
		$items = $helper->getConfigData('mfblog/general/items');
		$items_bigdesktop = $helper->getConfigData('mfblog/general/items_bigdesktop');
		$items_smalldesktop = $helper->getConfigData('mfblog/general/items_smalldesktop');
		$items_bigtablet = $helper->getConfigData('mfblog/general/items_bigtablet');
		$items_tablet = $helper->getConfigData('mfblog/general/items_tablet');
		$items_smalltablet = $helper->getConfigData('mfblog/general/items_smalltablet');
		$items_mobile = $helper->getConfigData('mfblog/general/items_mobile');
		$auto = $helper->getConfigData('mfblog/general/auto') ? 'true' : 'false';
		$autoplaytimeout = $helper->getConfigData('mfblog/general/autoplaytimeout');
		$autoplayhoverpause = $helper->getConfigData('mfblog/general/autoplayhoverpause') ? 'true' : 'false';
		$dots = $helper->getConfigData('mfblog/general/dots') ? 'true' : 'false';
		$rewind = $helper->getConfigData('mfblog/general/rewind') ? 'true' : 'false';
		$nav = $helper->getConfigData('mfblog/general/nav') ? 'true' : 'false';
		$navnext = $helper->getConfigData('mfblog/general/navnext');
		$navprev = $helper->getConfigData('mfblog/general/navprev');
		$stagepadding = $helper->getConfigData('mfblog/general/stagepadding');
		$touchdrag = $helper->getConfigData('mfblog/general/touchdrag') ? 'true' : 'false';
		$mousedrag = $helper->getConfigData('mfblog/general/mousedrag') ? 'true' : 'false';
		$center = $helper->getConfigData('mfblog/general/center') ? 'true' : 'false';
		$loop = $helper->getConfigData('mfblog/general/loop') ? 'true' : 'false';
		$margin = $helper->getConfigData('mfblog/general/margin');
		$speed = $helper->getConfigData('mfblog/general/speed');
		$rtl = $helper->getConfigData('mfblog/general/rtl') ? 'true' : 'true';
		
	?>
    <div class="block related">
        <div class="block-title title rokan-title"> 
			<h3>
				<strong id="block-relatedposts-heading">
					<?php echo __('Related Posts') ?>
				</strong>
			</h3>
        </div>
        <div class="block-content post-list-wrapper">
			<div class="blog-list-post owl-carousel owl-theme" data-rtl="<?php echo $rtl;?>" data-items="3" data-bigdesktop="3" data-smalldesktop="2" data-bigtablet="<?php echo $items_bigtablet;?>" data-tablet="2" data-smalltablet="1" data-mobile="1" data-margin="30" data-loop="<?php echo $loop;?>" data-center="<?php echo $center;?>" data-mousedrag="<?php echo $mousedrag;?>" data-touchdrag="<?php echo $touchdrag;?>" data-stagepadding="<?php echo $stagepadding;?>" data-nav="<?php echo $nav;?>" data-navnext="<?php echo $navnext;?>" data-navprev="<?php echo $navprev;?>" data-rewind="<?php echo $rewind;?>" data-dots="<?php echo $dots;?>" data-autoplay="<?php echo $auto;?>" data-autoplaytimeout="<?php echo $autoplaytimeout;?>" data-autoplayhoverpause="<?php echo $autoplayhoverpause;?>" data-speed="<?php echo $speed;?>">
            <?php foreach ($_postCollection as $_post) { ?>
				<div class="item-post-full post-holder post-holder-<?php echo $_post->getId() ?> <?php if ($featuredImage) { ?>has-thumb<?php } ?>">
					<div class="post-item">
						<div class="blog-post-thumb">
							<div class="post-ftimg-hld">
								<?php if ($featuredImage = $_post->getFeaturedImage()) { ?>
									<?php
									$featuredImgAlt = $_post->getData('featured_img_alt');
									if (!$featuredImgAlt) {
										$featuredImgAlt = $_postName;
									}
									?>
									<a class="post-item-link" href="<?= /*@noEscape*/ $_postUrl ?>">
										<img src="<?= $block->escapeUrl($featuredImage) ?>" alt="<?= $block->escapeHtml($featuredImgAlt) ?>" />
									</a>
								<?php } ?>
							</div>
						</div>
						<div class="blog-post-info">
							<div class="post-header">
								<div class="post-title-holder clearfix">
									<h2 class="post-title">
										<a class="post-item-link"
										   href="<?= /*@noEscape*/ $_postUrl ?>">
											<?= /*@noEscape*/ $_postName ?>
										</a>
									</h2>
								</div>
								<?= /*@noEscape*/ $block->getInfoHtml() ?>
							</div>
							<?php if ($_categoriesCount = $_post->getCategoriesCount()) { ?>
								<div class="item post-categories">
									<?php $n = 0; ?>
									<?php foreach ($_post->getParentCategories() as $ct) { ?>
										<?php $n++; ?>
										<a title="<?= $block->escapeHtml($ct->getTitle()) ?>"
										   href="<?= $block->escapeUrl($ct->getCategoryUrl()) ?>"
										><?= $block->escapeHtml($ct->getTitle()) ?></a><?= /*@noEscape*/ ($n != $_categoriesCount) ? ',' : '' ?>
									<?php } ?>
								</div>
							<?php } ?>
							<div class="post-content">
								<div class="post-description clearfix">
									<div class="post-text-hld clearfix">
										<?= /*@noEscape*/ $block->getShorContent() ?>
									</div>
								</div>
							</div>
							<div class="post-bottom">
								<div class="flex-layout space-between no-wrap">
									<a class="post-read-more"
									   href="<?= /*@noEscape*/ $_postUrl ?>"
									   title="<?= /*@noEscape*/ $_postName ?>"
									   >
										<?= $block->escapeHtml(__('Read more')) ?>
									</a>
									<?php if ($_post->isPublishDateEnabled()) { ?>
										<div class="item post-posed-date">
											<span class="label"><?= $block->escapeHtml(__('Posted:')) ?></span>
											<span class="value"><?= $block->escapeHtml($_post->getPublishDate()) ?></span>
										</div>
									<?php } ?>
								</div>
							</div>
						</div>
					</div>
				</div>
            <?php } ?>
			</div>
        </div>
    </div>
    <?php } ?>
<?php } ?>