<?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' : 'false';
		
	?>
    <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="<?php echo $items;?>" data-bigdesktop="<?php echo $items_bigdesktop;?>" data-smalldesktop="<?php echo $items_smalldesktop;?>" data-bigtablet="<?php echo $items_bigtablet;?>" data-tablet="<?php echo $items_tablet;?>" data-smalltablet="<?php echo $items_smalltablet;?>" data-mobile="<?php echo $items_mobile;?>" data-margin="<?php echo $margin;?>" 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-<?php echo $_post->getId() ?>">
					<div class="blog-post-thumb">
						<?php if ($featuredImage = $_post->getFeaturedImage()) { ?>
							<?php
							$featuredImgAlt = $_post->getData('featured_img_alt');
							if (!$featuredImgAlt) {
								$featuredImgAlt = $_postName;
							}
							?>
							<img src="<?= $block->escapeUrl($featuredImage) ?>" alt="<?= $block->escapeHtml($featuredImgAlt) ?>" />
						<?php } ?>
						<div class="time-conment">
							<?php 
								$date = $_post->getPublishTime();
							?>
							<span class="date"><?php echo date('d', strtotime($_post->getPublishTime())); ?> <?php echo date('M', strtotime($_post->getPublishTime())); ?></span>	
						</div>	
					</div>
					<div class="blog-post-info">
						<div class="post-category-name">
							<?php echo $this->getInfoHtml() ?>
						</div>
						<h3 class="post-title"><a href="<?= $block->escapeUrl($_post->getPostUrl()) ?>"><?php echo $block->escapeHtml($_post->getTitle()) ?></a></h3> 	
						<div class="desc">
							<?php echo $_post->getShortContent() ?>
						</div>
						<div class="post-info-bottom clearfix">
							<a class="readmore" href="<?= $block->escapeUrl($_post->getPostUrl()) ?>">
								<?php echo __('Read more') ?>
							</a>
						</div>
					</div>
				</div>
            <?php } ?>
			</div>
        </div>
    </div>
    <?php } ?>
<?php } ?>